示例#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();
 }