55using Microsoft . AspNetCore . Http ;
66using Microsoft . AspNetCore . Mvc ;
77using SharpRepository . Repository ;
8- using SharpRepository . CoreWebClient . Models ;
8+ using SharpRepository . CoreMvc . Models ;
99
10- namespace SharpRepository . CoreWebClient . Controllers
10+ namespace SharpRepository . CoreMvc . Controllers
1111{
1212 public class ContactsController : Controller
1313 {
14- protected IRepository < Contact , int > repository ;
14+ protected IRepository < Contact , string > repository ;
1515
16- public ContactsController ( IRepository < Contact , int > repository )
16+ public ContactsController ( IRepository < Contact , string > repository )
1717 {
1818 this . repository = repository ;
1919 }
@@ -27,7 +27,7 @@ public ActionResult Index()
2727 }
2828
2929 // GET: Contacts/Details/5
30- public ActionResult Details ( int id )
30+ public ActionResult Details ( string id )
3131 {
3232 var contact = repository . Get ( id ) ;
3333
@@ -45,20 +45,13 @@ public ActionResult Create()
4545 [ ValidateAntiForgeryToken ]
4646 public ActionResult Create ( Contact contact )
4747 {
48- try
49- {
50- repository . Add ( contact ) ;
48+ repository . Add ( contact ) ;
5149
52- return RedirectToAction ( nameof ( Index ) ) ;
53- }
54- catch
55- {
56- return View ( ) ;
57- }
50+ return RedirectToAction ( nameof ( Index ) ) ;
5851 }
5952
6053 // GET: Contacts/Edit/5
61- public ActionResult Edit ( int id )
54+ public ActionResult Edit ( string id )
6255 {
6356 var contact = repository . Get ( id ) ;
6457 return View ( contact ) ;
@@ -67,7 +60,7 @@ public ActionResult Edit(int id)
6760 // POST: Contacts/Edit/5
6861 [ HttpPost ]
6962 [ ValidateAntiForgeryToken ]
70- public ActionResult Edit ( int id , Contact contact )
63+ public ActionResult Edit ( string id , Contact contact )
7164 {
7265 try
7366 {
@@ -82,7 +75,7 @@ public ActionResult Edit(int id, Contact contact)
8275 }
8376
8477 // GET: Contacts/Delete/5
85- public ActionResult Delete ( int id )
78+ public ActionResult Delete ( string id )
8679 {
8780 var contact = repository . Get ( id ) ;
8881
@@ -92,7 +85,7 @@ public ActionResult Delete(int id)
9285 // POST: Contacts/Delete/5
9386 [ HttpPost ]
9487 [ ValidateAntiForgeryToken ]
95- public ActionResult Delete ( int id , IFormCollection collection )
88+ public ActionResult Delete ( string id , IFormCollection collection )
9689 {
9790 try
9891 {
0 commit comments