{"id":57,"date":"2021-03-17T14:20:26","date_gmt":"2021-03-17T05:20:26","guid":{"rendered":"https:\/\/mvc.auctionpro.co.kr\/?page_id=57"},"modified":"2021-03-17T14:21:05","modified_gmt":"2021-03-17T05:21:05","slug":"model-class","status":"publish","type":"page","link":"https:\/\/mvc.auctionpro.co.kr\/?page_id=57","title":{"rendered":"Model class"},"content":{"rendered":"<h3>Remark :<br \/>\nModel class<\/h3>\n<pre class=\"lang:default decode:true \" title=\"Models Employee.cs\">using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Threading.Tasks;\r\nusing System.ComponentModel;  \/\/ [DisplayName(\"Employee ID\")]\r\nusing System.ComponentModel.DataAnnotations; \/\/ [Required]   [Range(1000,100000)]\r\n\r\nnamespace WebApplication8.Models\r\n{\r\n    public class Employee\r\n    {\r\n        [DisplayName(\"Employee ID\")]\r\n        [Required]\r\n        public int EmpId { get; set; }\r\n\r\n        [DisplayName(\"Employee Name\")]\r\n        [Required]\r\n        public string EmpName { get; set; }\r\n\r\n        [DisplayName(\"Employee Salary\")]\r\n        [Required]\r\n        [Range(1000,100000)]\r\n        public float EmpSalary { get; set; }\r\n    }\r\n}<\/pre>\n<pre class=\"lang:default decode:true \" title=\"Controllers EmployeeController.cs\">using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Threading.Tasks;\r\nusing Microsoft.AspNetCore.Mvc;\r\nusing WebApplication8.Models; \/\/models\r\n\r\nnamespace WebApplication8.Controllers\r\n{\r\n    public class EmployeeController : Controller\r\n    {\r\n        static List&lt;Employee&gt; allEmployee = new List&lt;Employee&gt;()\r\n        {\r\n           new Employee {EmpId=1, EmpName=\"Hong gildong\", EmpSalary =12000},\r\n           new Employee {EmpId =2,EmpName=\"Kim honggil\", EmpSalary=14000}\r\n        };\r\n\r\n        public IActionResult Index()\r\n        {\r\n            return View(allEmployee);\r\n        }\r\n\r\n        public IActionResult Create()\r\n        {\r\n            return View();\r\n        }\r\n        [HttpPost]\r\n        public IActionResult Create(Employee emp)\r\n        {\r\n            allEmployee.Add(emp);\r\n            return RedirectToAction(\"Index\");\r\n        }\r\n\r\n    }\r\n}<\/pre>\n<pre class=\"lang:default decode:true \" title=\"Views Employee index.cshml\">@model IEnumerable&lt;WebApplication8.Models.Employee&gt;\r\n\r\n@{\r\n    ViewData[\"Title\"] = \"EmplyeeIndex\";\r\n}\r\n\r\n&lt;h1&gt;EmplyeeIndex&lt;\/h1&gt;\r\n\r\n&lt;p&gt;\r\n    &lt;a asp-action=\"Create\"&gt;Create New&lt;\/a&gt;\r\n&lt;\/p&gt;\r\n&lt;table class=\"table\"&gt;\r\n    &lt;thead&gt;\r\n        &lt;tr&gt;\r\n            &lt;th&gt;\r\n                @Html.DisplayNameFor(model =&gt; model.EmpId)\r\n            &lt;\/th&gt;\r\n            &lt;th&gt;\r\n                @Html.DisplayNameFor(model =&gt; model.EmpName)\r\n            &lt;\/th&gt;\r\n            &lt;th&gt;\r\n                @Html.DisplayNameFor(model =&gt; model.EmpSalary)\r\n            &lt;\/th&gt;\r\n            &lt;th&gt;&lt;\/th&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/thead&gt;\r\n    &lt;tbody&gt;\r\n@foreach (var item in Model) {\r\n        &lt;tr&gt;\r\n            &lt;td&gt;\r\n                @Html.DisplayFor(modelItem =&gt; item.EmpId)\r\n            &lt;\/td&gt;\r\n            &lt;td&gt;\r\n                @Html.DisplayFor(modelItem =&gt; item.EmpName)\r\n            &lt;\/td&gt;\r\n            &lt;td&gt;\r\n                @Html.DisplayFor(modelItem =&gt; item.EmpSalary)\r\n            &lt;\/td&gt;\r\n            &lt;td&gt;\r\n                @Html.ActionLink(\"Edit\", \"Edit\", new { \/* id=item.PrimaryKey *\/ }) |\r\n                @Html.ActionLink(\"Details\", \"Details\", new { \/* id=item.PrimaryKey *\/ }) |\r\n                @Html.ActionLink(\"Delete\", \"Delete\", new { \/* id=item.PrimaryKey *\/ })\r\n            &lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n}\r\n    &lt;\/tbody&gt;\r\n&lt;\/table&gt;\r\n<\/pre>\n<pre class=\"lang:default decode:true \" title=\"Views Employee Create.cshml\">@model WebApplication8.Models.Employee \/\/model\r\n\r\n@{\r\n    ViewData[\"Title\"] = \"Create\";\r\n}\r\n\r\n&lt;h1&gt;Create&lt;\/h1&gt;\r\n\r\n@using (Html.BeginForm())\r\n{\r\n    @Html.ValidationSummary(true);\r\n    @Html.LabelFor(model =&gt; model.EmpId)\r\n    @:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\r\n    @Html.EditorFor(model =&gt; model.EmpId)\r\n    @Html.ValidationMessageFor(model =&gt; model.EmpId)\r\n    &lt;br \/&gt;\r\n\r\n    @Html.ValidationSummary(true);\r\n    @Html.LabelFor(model =&gt; model.EmpName)\r\n    @:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\r\n    @Html.EditorFor(model =&gt; model.EmpName)\r\n    @Html.ValidationMessageFor(model =&gt; model.EmpName)\r\n    &lt;br \/&gt;\r\n\r\n    @Html.ValidationSummary(true);\r\n    @Html.LabelFor(model =&gt; model.EmpSalary)\r\n    @:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;\r\n    @Html.EditorFor(model =&gt; model.EmpSalary)\r\n    @Html.ValidationMessageFor(model =&gt; model.EmpSalary)\r\n    &lt;br \/&gt;\r\n\r\n    &lt;input type=\"submit\" value=\"Submit\" \/&gt;\r\n}\r\n\r\n@*\r\n    @section Scripts{\r\n        \/\/@Scripts.Render(\"~\/bundles\/jueeryval\")\r\n    }\r\n*@<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-59 size-full\" src=\"https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index.jpg\" alt=\"\" width=\"909\" height=\"315\" srcset=\"https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index.jpg 909w, https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index-300x104.jpg 300w, https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index-768x266.jpg 768w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-58\" src=\"https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_Create.jpg\" alt=\"\" width=\"758\" height=\"220\" srcset=\"https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_Create.jpg 758w, https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_Create-300x87.jpg 300w\" sizes=\"auto, (max-width: 758px) 100vw, 758px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-60 size-full\" src=\"https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index02.jpg\" alt=\"\" width=\"962\" height=\"354\" srcset=\"https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index02.jpg 962w, https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index02-300x110.jpg 300w, https:\/\/mvc.auctionpro.co.kr\/wp-content\/uploads\/2021\/03\/Employee_index02-768x283.jpg 768w\" sizes=\"auto, (max-width: 962px) 100vw, 962px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Remark : Model class using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.ComponentModel; \/\/ [DisplayName(&#8220;Employee ID&#8221;)] using System.ComponentModel.DataAnnotations; \/\/ [Required] [Range(1000,100000)] namespace WebApplication8.Models { public class Employee { [DisplayName(&#8220;Employee ID&#8221;)] [Required] public int EmpId { get; set; } [DisplayName(&#8220;Employee Name&#8221;)] [Required] public string EmpName { get; set; } [DisplayName(&#8220;Employee Salary&#8221;)] [Required] [Range(1000,100000)] public float\u2026 <span class=\"read-more\"><a href=\"https:\/\/mvc.auctionpro.co.kr\/?page_id=57\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-57","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/pages\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=57"}],"version-history":[{"count":2,"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/pages\/57\/revisions"}],"predecessor-version":[{"id":62,"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/pages\/57\/revisions\/62"}],"wp:attachment":[{"href":"https:\/\/mvc.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}