{"id":48,"date":"2025-10-08T09:55:31","date_gmt":"2025-10-08T07:55:31","guid":{"rendered":"https:\/\/kaurpakaste24.thkit.ee\/wp\/?page_id=48"},"modified":"2025-10-20T15:33:31","modified_gmt":"2025-10-20T13:33:31","slug":"delinquents-controller-mudel-ja-view","status":"publish","type":"page","link":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/","title":{"rendered":"Delinquents Controller, Model ja View"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Controller<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The SchoolContext _context tells the Controller and View what the database looks like and all the information in it.\n\nIndex lets us view all the Delinquents information in general using the ToListAsync() method which puts all the books into a table.\n\nCreate first gives us the Create view and then once the information is given, it checks that the model is correct and if so, adds it to the database and takes you back to the Index.\n\nIt also uses SaveChangesAsync to save the information\n\nDelete deletes the given selection after checking that it exists. It first uses FirstorDefaultAsync which returns the first element of the sequence asynchronously. And uses the Lambda method to briefly show the anonymous method.\n\nAnd then saves it to the database after deleting the selected object.\n\nDetails lets us view more detailed information about the given object. It also uses the FirstorDefaultAsync and Lambda methods.\n\nEdit lets us modify the given object. It uses the FirstorDefaultAsync and Lambda methods. It also has a post method which then saves everything that was changed.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.AspNetCore.Mvc.Rendering;\nusing Microsoft.EntityFrameworkCore;\nusing TallinnaRakenduslikKolledzKaur.Data;\nusing TallinnaRakenduslikKolledzKaur.Models;\n\nnamespace TallinnaRakenduslikKolledzKaur.Controllers\n{\n    public class DelinquentsController : Controller\n    {\n        private readonly SchoolContext _context;\n        public DelinquentsController(SchoolContext context)\n        {\n            _context = context;\n        }\n        public async Task&lt;IActionResult&gt; Index()\n        {\n            return View(await _context.Delinquents.ToListAsync());\n        }\n        \n        &#x5B;HttpGet]\n        public IActionResult Create()\n        {\n            return View();\n        }\n        &#x5B;HttpPost]\n        &#x5B;ValidateAntiForgeryToken]\n        public async Task&lt;IActionResult&gt; Create(Delinquent delinquent)\n        {\n            if (ModelState.IsValid)\n            {\n                _context.Delinquents.Add(delinquent);\n                await _context.SaveChangesAsync();\n            }\n\n            return RedirectToAction(&quot;Index&quot;);\n        }\n        &#x5B;HttpGet]\n        public async Task&lt;IActionResult&gt; Details(int? Id)\n        {\n            if (Id == null)\n            {\n                return NotFound();\n            }\n            var delinquent = await _context.Delinquents.FirstOrDefaultAsync(d =&gt; d.BreakerId == Id);\n            if (delinquent == null)\n            {\n                return NotFound();\n            }\n            return View(delinquent);\n        }\n\n        &#x5B;HttpGet]\n        public async Task&lt;IActionResult&gt; Edit(int? Id)\n        {\n            if (Id == null)\n            {\n                return NotFound();\n            }\n            var delinquent = await _context.Delinquents.FirstOrDefaultAsync(d =&gt; d.BreakerId == Id);\n            if (delinquent == null)\n            {\n                return NotFound();\n            }\n            _context.Delinquents.Update(delinquent);\n            return View(delinquent);\n        }\n        &#x5B;HttpPost, ActionName(&quot;Edit&quot;)]\n        &#x5B;ValidateAntiForgeryToken]\n        public async Task&lt;IActionResult&gt; EditConfirmed(&#x5B;Bind(&quot;BreakerId,FirstName,LastName,Violations,Description,Position&quot;)] Delinquent delinquent)\n        {\n            _context.Delinquents.Update(delinquent);\n            await _context.SaveChangesAsync();\n            return RedirectToAction(&quot;Index&quot;);\n        }\n\n        &#x5B;HttpGet]\n        public async Task&lt;IActionResult&gt; Delete(int? Id)\n        {\n            if (Id == null)\n            {\n                return NotFound();\n            }\n            var delinquent = await _context.Delinquents.FirstOrDefaultAsync(d =&gt; d.BreakerId == Id);\n            if (delinquent == null)\n            {\n                return NotFound();\n            }\n            return View(delinquent);\n        }\n\n        &#x5B;HttpPost]\n        &#x5B;ValidateAntiForgeryToken]\n        public async Task&lt;IActionResult&gt; Delete(Delinquent delinquent)\n        {\n            if (await _context.Delinquents.AnyAsync(d =&gt; d.BreakerId == delinquent.BreakerId))\n            {\n                _context.Delinquents.Remove(delinquent);\n                await _context.SaveChangesAsync();\n            }\n            return RedirectToAction(&quot;Index&quot;);\n        }\n    }\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Mudel<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System.ComponentModel.DataAnnotations;\n\nnamespace TallinnaRakenduslikKolledzKaur.Models\n{\n    public enum Violations\n    {\n        Vandalism, IPhoneUser, Smoking, Bullying, AI_User\n    }\n    public enum Positions\n    {\n        Student,Instructor\n    }\n    public class Delinquent\n    {\n        &#x5B;Key]\n        public int BreakerId { get; set; }\n        public string FirstName { get; set; }\n        public string LastName { get; set; }\n        public Violations Violations { get; set; }\n        public string? Description { get; set; }\n        public Positions Position {  get; set; }\n\n\n    }\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">View<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n@model TallinnaRakenduslikKolledzKaur.Models.Delinquent\n@{\n\tViewData&#x5B;&quot;Title&quot;] = &quot;Uus Delinquent&quot;;\n}\n&lt;h1&gt;Tee uus delinquent&lt;\/h1&gt;\n&lt;h4&gt;Sisesta info:&lt;\/h4&gt;\n&lt;hr \/&gt;\n&lt;div class=&quot;row&quot;&gt;\n\t&lt;div class=&quot;col-md-4&quot;&gt;\n\t\t&lt;form asp-action=&quot;Create&quot;&gt;\n\t\t\t&lt;div asp-validation-summary=&quot;ModelOnly&quot; class=&quot;text-danger&quot;&gt;&lt;\/div&gt;\n\t\t\t&lt;!--&lt;div&gt;\n\t\t\t\t&lt;label asp-for=&quot;CourseId&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;input asp-for=&quot;CourseId&quot; class=&quot;form-control&quot; \/&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;CourseId&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt; --&gt;\n\t\t\t&lt;div&gt;\n\t\t\t\t&lt;label asp-for=&quot;FirstName&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;input asp-for=&quot;FirstName&quot; class=&quot;form-control&quot; \/&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;FirstName&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div&gt;\n\t\t\t\t&lt;label asp-for=&quot;LastName&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;input asp-for=&quot;LastName&quot; class=&quot;form-control&quot; \/&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;LastName&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div&gt;\n\t\t\t\t&lt;label asp-for=&quot;Description&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;input asp-for=&quot;Description&quot; class=&quot;form-control&quot; \/&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;Description&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div class=&quot;form-group&quot;&gt;\n\t\t\t\t&lt;label asp-for=&quot;Position&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;select asp-for=&quot;Position&quot; class=&quot;control-label&quot;&gt;\n\t\t\t\t\t&lt;option value=&quot;&quot;&gt;-- Select Position --&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Student&quot;&gt;Student&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Instructor&quot;&gt;Instructor&lt;\/option&gt;\n\t\t\t\t&lt;\/select&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;Position&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div class=&quot;form-group&quot;&gt;\n\t\t\t\t&lt;label asp-for=&quot;Violations&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;select asp-for=&quot;Violations&quot; class=&quot;control-label&quot;&gt;\n\t\t\t\t\t&lt;option value=&quot;&quot;&gt;-- Select Violation --&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;AI_User&quot;&gt;AI User&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Bullying&quot;&gt;Bully&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Smoking&quot;&gt;Smoker&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;IPhoneUser&quot;&gt;IPhone User&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Vandalism&quot;&gt;Vandalism&lt;\/option&gt;\n\t\t\t\t&lt;\/select&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;Violations&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div class=&quot;form-group&quot;&gt;\n\t\t\t\t&lt;input type=&quot;submit&quot; value=&quot;Tee uus&quot; class=&quot;btn btn-primary&quot; \/&gt; | &lt;a asp-action=&quot;Index&quot; class=&quot;btn btn-outline-primary&quot;&gt;T\u00fchista&lt;\/a&gt;\n\t\t\t&lt;\/div&gt;\n\t\t&lt;\/form&gt;\n\t&lt;\/div&gt;\n&lt;\/div&gt;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Delete<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n@model TallinnaRakenduslikKolledzKaur.Models.Delinquent\n\n@{\n\tViewData&#x5B;&quot;Title&quot;] = &quot;Kustuta Delinquent&quot;;\n}\n\n&lt;h1&gt;Kustuta Delinquent&lt;\/h1&gt;\n&lt;h3&gt;\n\tKas oled kindel et tahad kustudada @Html.DisplayFor(Model =&gt; Model.FirstName)\n&lt;\/h3&gt;\n&lt;div&gt;\n\t&lt;h4&gt;Delinquent&lt;\/h4&gt;\n\t&lt;hr \/&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.LastName)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayFor(Model =&gt; Model.LastName)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.FirstName)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayFor(Model =&gt; Model.FirstName)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.Violations)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayFor(Model =&gt; Model.Violations)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.Description)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayFor(Model =&gt; Model.Description)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.Position)&lt;\/dt&gt;\n\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayFor(Model =&gt; Model.Position)&lt;\/dt&gt;\n\n\t&lt;form asp-action=&quot;Delete&quot;&gt;\n\t\t&lt;input type=&quot;hidden&quot; asp-for=&quot;BreakerId&quot; \/&gt;\n\t\t&lt;input type=&quot;submit&quot; value=&quot;Kustuta Delinquent&quot; class=&quot;btn btn-danger&quot; \/&gt; | &lt;a asp-action=&quot;Index&quot;&gt;T\u00fchista&lt;\/a&gt;\n\t&lt;\/form&gt;\n&lt;\/div&gt;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Details<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n@model TallinnaRakenduslikKolledzKaur.Models.Delinquent\n\n@{\n\tViewData&#x5B;&quot;Title&quot;] = &quot;Viewing delinquents&quot;;\n}\n\n&lt;div&gt;\n\t&lt;h4&gt;Delinquent&lt;\/h4&gt;\n\t&lt;hr \/&gt;\n\t&lt;dl class=&quot;row&quot;&gt;\n\t\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.FirstName)&lt;\/dt&gt;\n\t\t&lt;dd class=&quot;col-sm-10&quot;&gt;@Html.DisplayFor(Model =&gt; Model.FirstName)&lt;\/dd&gt;\n\t&lt;\/dl&gt;\n\t&lt;dl class=&quot;row&quot;&gt;\n\t\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.LastName)&lt;\/dt&gt;\n\t\t&lt;dd class=&quot;col-sm-10&quot;&gt;@Html.DisplayFor(Model =&gt; Model.LastName)&lt;\/dd&gt;\n\t&lt;\/dl&gt;\n\t&lt;dl class=&quot;row&quot;&gt;\n\t\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.Violations)&lt;\/dt&gt;\n\t\t&lt;dd class=&quot;col-sm-10&quot;&gt;@Html.DisplayFor(Model =&gt; Model.Violations)&lt;\/dd&gt;\n\t&lt;\/dl&gt;\n\t&lt;dl class=&quot;row&quot;&gt;\n\t\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.Description)&lt;\/dt&gt;\n\t\t&lt;dd class=&quot;col-sm-10&quot;&gt;@Html.DisplayFor(Model =&gt; Model.Description)&lt;\/dd&gt;\n\t&lt;\/dl&gt;\n\t&lt;dl class=&quot;row&quot;&gt;\n\t\t&lt;dt class=&quot;col-sm-2&quot;&gt;@Html.DisplayNameFor(Model =&gt; Model.Position)&lt;\/dt&gt;\n\t\t&lt;dd class=&quot;col-sm-10&quot;&gt;@Html.DisplayFor(Model =&gt; Model.Position)&lt;\/dd&gt;\n\t&lt;\/dl&gt;\n&lt;\/div&gt;\n\n\n&lt;form asp-action=&quot;Tagasi&quot;&gt;\n\t&lt;input type=&quot;hidden&quot; asp-for=&quot;BreakerId&quot; \/&gt;\n\t&lt;a asp-action=&quot;Index&quot;&gt;Tagasi&lt;\/a&gt;\n&lt;\/form&gt;\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Edit<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n@model TallinnaRakenduslikKolledzKaur.Models.Delinquent\n\n@{\n\tViewData&#x5B;&quot;Title&quot;] = &quot;Muuda Delinquent&quot;;\n}\n\n&lt;h1&gt;Muuda Delinquent&lt;\/h1&gt;\n&lt;hr \/&gt;\n&lt;div class=&quot;row&quot;&gt;\n\t&lt;div class=&quot;col-md-4&quot;&gt;\n\t\t&lt;form asp-action=&quot;Edit&quot;&gt;\n\t\t\t&lt;input type=&quot;hidden&quot; asp-for=&quot;@Model.BreakerId&quot; \/&gt;\n\t\t\t&lt;div asp-validation-summary=&quot;ModelOnly&quot; class=&quot;text-danger&quot;&gt;&lt;\/div&gt;\n\n\t\t\t&lt;div&gt;\n\t\t\t\t&lt;label asp-for=&quot;FirstName&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;input asp-for=&quot;FirstName&quot; class=&quot;form-control&quot; \/&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;FirstName&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div&gt;\n\t\t\t\t&lt;label asp-for=&quot;LastName&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;input asp-for=&quot;LastName&quot; class=&quot;form-control&quot; \/&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;LastName&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div&gt;\n\t\t\t\t&lt;label asp-for=&quot;Description&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;input asp-for=&quot;Description&quot; class=&quot;form-control&quot; \/&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;Description&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div class=&quot;form-group&quot;&gt;\n\t\t\t\t&lt;label asp-for=&quot;Position&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;select asp-for=&quot;Position&quot; class=&quot;control-label&quot;&gt;\n\t\t\t\t\t&lt;option value=&quot;&quot;&gt;-- Select Position --&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Student&quot;&gt;Student&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Instructor&quot;&gt;Instructor&lt;\/option&gt;\n\t\t\t\t&lt;\/select&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;Position&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div class=&quot;form-group&quot;&gt;\n\t\t\t\t&lt;label asp-for=&quot;Violations&quot; class=&quot;control-label&quot;&gt;&lt;\/label&gt;\n\t\t\t\t&lt;select asp-for=&quot;Violations&quot; class=&quot;control-label&quot;&gt;\n\t\t\t\t\t&lt;option value=&quot;&quot;&gt;-- Select Violation --&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;AI_User&quot;&gt;AI User&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Bullying&quot;&gt;Bully&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Smoking&quot;&gt;Smoker&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;IPhoneUser&quot;&gt;IPhone User&lt;\/option&gt;\n\t\t\t\t\t&lt;option value=&quot;Vandalism&quot;&gt;Vandalism&lt;\/option&gt;\n\t\t\t\t&lt;\/select&gt;\n\t\t\t\t&lt;span asp-validation-for=&quot;Violations&quot; class=&quot;text-danger&quot;&gt;&lt;\/span&gt;\n\t\t\t&lt;\/div&gt;\n\t\t\t&lt;div class=&quot;form-group&quot;&gt;\n\t\t\t\t&lt;input type=&quot;submit&quot; asp-route-id=&quot;@Model.BreakerId&quot; value=&quot;Edit&quot; class=&quot;btn btn-primary&quot; \/&gt;\n\t\t\t&lt;\/div&gt;\n\t\t&lt;\/form&gt;\n\t&lt;\/div&gt;\n&lt;\/div&gt;\n\n&lt;div&gt;\n\t&lt;a asp-action=&quot;Index&quot;&gt;Mine tagasi loendisse&lt;\/a&gt;\n&lt;\/div&gt;\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Index<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n@model IEnumerable&lt;TallinnaRakenduslikKolledzKaur.Models.Delinquent&gt;\n@{\n\tViewData&#x5B;&quot;Title&quot;] = &quot;Delinquents&quot;;\n}\n&lt;h1&gt;Delinquents Loend:&lt;\/h1&gt;\n&lt;p&gt;\n\t&lt;a asp-action=&quot;Create&quot;&gt;Sisesta Delinquent&lt;\/a&gt;\n&lt;\/p&gt;\n&lt;table class=&quot;table&quot;&gt;\n\t&lt;thead&gt;\n\t\t&lt;tr&gt;\n\t\t\t&lt;th&gt;\n\t\t\t\t@Html.DisplayNameFor(Model =&gt; Model.BreakerId)\n\t\t\t&lt;\/th&gt;\n\t\t\t&lt;th&gt;\n\t\t\t\t@Html.DisplayNameFor(Model =&gt; Model.LastName)\n\t\t\t&lt;\/th&gt;\n\t\t\t&lt;th&gt;\n\t\t\t\t@Html.DisplayNameFor(Model =&gt; Model.FirstName)\n\t\t\t&lt;\/th&gt;\n\t\t\t&lt;th&gt;\n\t\t\t\t@Html.DisplayNameFor(Model =&gt; Model.Violations)\n\t\t\t&lt;\/th&gt;\n\t\t\t&lt;th&gt;\n\t\t\t\t@Html.DisplayNameFor(Model =&gt; Model.Description)\n\t\t\t&lt;\/th&gt;\n\t\t\t&lt;th&gt;\n\t\t\t\t@Html.DisplayNameFor(Model =&gt; Model.Position)\n\t\t\t&lt;\/th&gt;\n\t\t\t&lt;th&gt;T\u00f6\u00f6riistad&lt;\/th&gt;\n\t\t&lt;\/tr&gt;\n\t&lt;\/thead&gt;\n\t&lt;tbody&gt;\n\t\t@foreach (var delinquent in Model)\n\t\t{\n\t\t\t&lt;tr&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t@Html.DisplayFor(modelItem =&gt; delinquent.BreakerId)\n\t\t\t\t&lt;\/td&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t@Html.DisplayFor(modelItem =&gt; delinquent.LastName)\n\t\t\t\t&lt;\/td&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t@Html.DisplayFor(modelItem =&gt; delinquent.FirstName)\n\t\t\t\t&lt;\/td&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t@Html.DisplayFor(modelItem =&gt; delinquent.Violations)\n\t\t\t\t&lt;\/td&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t@Html.DisplayFor(modelItem =&gt; delinquent.Description)\n\t\t\t\t&lt;\/td&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t@Html.DisplayFor(modelItem =&gt; delinquent.Position)\n\t\t\t\t&lt;\/td&gt;\n\t\t\t\t&lt;td&gt;\n\t\t\t\t\t&lt;a asp-action=&quot;Edit&quot; asp-route-id=&quot;@delinquent.BreakerId&quot;&gt;Muuda&lt;\/a&gt;\n\t\t\t\t\t&lt;a asp-action=&quot;Details&quot; asp-route-id=&quot;@delinquent.BreakerId&quot;&gt;Vaata&lt;\/a&gt;\n\t\t\t\t\t&lt;a asp-action=&quot;Delete&quot; asp-route-id=&quot;@delinquent.BreakerId&quot;&gt;Kustuta&lt;\/a&gt;\n\t\t\t\t&lt;\/td&gt;\n\t\t\t&lt;\/tr&gt;\n\t\t}\n\t&lt;\/tbody&gt;\n&lt;\/table&gt;\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Controller The SchoolContext _context tells the Controller and View what the database looks like and all the information in it. Index lets us view all the Delinquents information in general using the ToListAsync() method which puts all the books into a table. Create first gives us the Create view and then once the information is given, it checks that the model is correct and if so, adds it to the database and takes you back to the Index. It also uses SaveChangesAsync to save the information Delete deletes the given selection after checking that it exists. It first uses FirstorDefaultAsync which returns the first element of the sequence asynchronously. And uses the Lambda method to briefly show the anonymous method. And then saves it to the database after deleting the selected object. Details lets us view more detailed information about the given object. It also uses the FirstorDefaultAsync and Lambda methods. Edit lets us modify the given object. It uses the FirstorDefaultAsync and Lambda methods. It also has a post method which then saves everything that was changed. Mudel View Create Delete Details Edit Index<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-48","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Delinquents Controller, Model ja View - Kaur portfoolio \/ English<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Delinquents Controller, Model ja View - Kaur portfoolio \/ English\" \/>\n<meta property=\"og:description\" content=\"Controller The SchoolContext _context tells the Controller and View what the database looks like and all the information in it. Index lets us view all the Delinquents information in general using the ToListAsync() method which puts all the books into a table. Create first gives us the Create view and then once the information is given, it checks that the model is correct and if so, adds it to the database and takes you back to the Index. It also uses SaveChangesAsync to save the information Delete deletes the given selection after checking that it exists. It first uses FirstorDefaultAsync which returns the first element of the sequence asynchronously. And uses the Lambda method to briefly show the anonymous method. And then saves it to the database after deleting the selected object. Details lets us view more detailed information about the given object. It also uses the FirstorDefaultAsync and Lambda methods. Edit lets us modify the given object. It uses the FirstorDefaultAsync and Lambda methods. It also has a post method which then saves everything that was changed. Mudel View Create Delete Details Edit Index\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/\" \/>\n<meta property=\"og:site_name\" content=\"Kaur portfoolio \/ English\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-20T13:33:31+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/delinquents-controller-mudel-ja-view\\\/\",\"url\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/delinquents-controller-mudel-ja-view\\\/\",\"name\":\"Delinquents Controller, Model ja View - Kaur portfoolio \\\/ English\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/#website\"},\"datePublished\":\"2025-10-08T07:55:31+00:00\",\"dateModified\":\"2025-10-20T13:33:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/delinquents-controller-mudel-ja-view\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/delinquents-controller-mudel-ja-view\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/delinquents-controller-mudel-ja-view\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Delinquents Controller, Model ja View\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/#website\",\"url\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/\",\"name\":\"Kaur portfoolio \\\/ English\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kaurpakaste24.thkit.ee\\\/wp\\\/eng\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Delinquents Controller, Model ja View - Kaur portfoolio \/ English","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/","og_locale":"en_US","og_type":"article","og_title":"Delinquents Controller, Model ja View - Kaur portfoolio \/ English","og_description":"Controller The SchoolContext _context tells the Controller and View what the database looks like and all the information in it. Index lets us view all the Delinquents information in general using the ToListAsync() method which puts all the books into a table. Create first gives us the Create view and then once the information is given, it checks that the model is correct and if so, adds it to the database and takes you back to the Index. It also uses SaveChangesAsync to save the information Delete deletes the given selection after checking that it exists. It first uses FirstorDefaultAsync which returns the first element of the sequence asynchronously. And uses the Lambda method to briefly show the anonymous method. And then saves it to the database after deleting the selected object. Details lets us view more detailed information about the given object. It also uses the FirstorDefaultAsync and Lambda methods. Edit lets us modify the given object. It uses the FirstorDefaultAsync and Lambda methods. It also has a post method which then saves everything that was changed. Mudel View Create Delete Details Edit Index","og_url":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/","og_site_name":"Kaur portfoolio \/ English","article_modified_time":"2025-10-20T13:33:31+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/","url":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/","name":"Delinquents Controller, Model ja View - Kaur portfoolio \/ English","isPartOf":{"@id":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/#website"},"datePublished":"2025-10-08T07:55:31+00:00","dateModified":"2025-10-20T13:33:31+00:00","breadcrumb":{"@id":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/delinquents-controller-mudel-ja-view\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/"},{"@type":"ListItem","position":2,"name":"Delinquents Controller, Model ja View"}]},{"@type":"WebSite","@id":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/#website","url":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/","name":"Kaur portfoolio \/ English","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/pages\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":2,"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/pages\/48\/revisions"}],"predecessor-version":[{"id":193,"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/pages\/48\/revisions\/193"}],"wp:attachment":[{"href":"https:\/\/kaurpakaste24.thkit.ee\/wp\/eng\/wp-json\/wp\/v2\/media?parent=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}