Пример #1
0
 public IActionResult Create(Contact contact)
 {
     ModelState.Clear();
     TryValidateModel(contact);
     if (ModelState.IsValid)
     {
         using (var db = new ContactsContext())
         {
             db.Contacts.Add(contact);
             var count = db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     return View(contact);
 }
Пример #2
0
 public HomeController()
 {
     _db = new ContactsContext();
 }