File tree Expand file tree Collapse file tree 3 files changed +71
-1
lines changed Expand file tree Collapse file tree 3 files changed +71
-1
lines changed Original file line number Diff line number Diff line change @@ -66,5 +66,20 @@ public IActionResult Delete(int id)
6666 return RedirectToAction ( nameof ( Index ) ) ;
6767 }
6868
69+ public IActionResult Details ( int ? id )
70+ {
71+ if ( id == null )
72+ {
73+ return NotFound ( ) ;
74+ }
75+
76+ var obj = _sellerService . FindById ( id . Value ) ;
77+ if ( obj == null )
78+ {
79+ return NotFound ( ) ;
80+ }
81+ return View ( obj ) ;
82+ }
83+
6984 }
7085}
Original file line number Diff line number Diff line change 33using System . Linq ;
44using System . Threading . Tasks ;
55using SalesWebMvc . Models ;
6+ using Microsoft . EntityFrameworkCore ;
67
78namespace SalesWebMvc . Services
89{
@@ -28,7 +29,7 @@ public void Insert(Seller obj)
2829
2930 public Seller FindById ( int id )
3031 {
31- return _context . Seller . FirstOrDefault ( obj => obj . Id == id ) ;
32+ return _context . Seller . Include ( obj => obj . Department ) . FirstOrDefault ( obj => obj . Id == id ) ;
3233 }
3334
3435 public void Remove ( int id )
Original file line number Diff line number Diff line change 1+ @model SalesWebMvc .Models .Seller
2+
3+ @{
4+ ViewData [" Title" ] = " Details" ;
5+ }
6+
7+ <h2 >@ViewData ["Title"]</h2 >
8+
9+
10+ <div >
11+ <h4 >Seller</h4 >
12+ <hr />
13+ <dl class =" dl-horizontal" >
14+ <dt >
15+ @Html.DisplayNameFor(model => model.Name)
16+ </dt >
17+ <dd >
18+ @Html.DisplayFor(model => model.Name)
19+ </dd >
20+
21+ <dt >
22+ @Html.DisplayNameFor(model => model.Email)
23+ </dt >
24+ <dd >
25+ @Html.DisplayFor(model => model.Email)
26+ </dd >
27+
28+ <dt >
29+ @Html.DisplayNameFor(model => model.BirthDate)
30+ </dt >
31+ <dd >
32+ @Html.DisplayFor(model => model.BirthDate)
33+ </dd >
34+
35+ <dt >
36+ @Html.DisplayNameFor(model => model.BaseSalary)
37+ </dt >
38+ <dd >
39+ @Html.DisplayFor(model => model.BaseSalary)
40+ </dd >
41+ <dt >
42+ @Html.DisplayNameFor(model => model.Department)
43+ </dt >
44+ <dd >
45+ @Html.DisplayFor(model => model.Department.Name)
46+ </dd >
47+ </dl >
48+
49+
50+ </div >
51+ <div >
52+ <a asp-action =" Edit" asp-route-id =" @Model.Id" class =" btn btn-default" >Edit</a >
53+ <a asp-action =" Index" >Back to list</a >
54+ </div >
You can’t perform that action at this time.
0 commit comments