Esempio n. 1
0
 public ActionResult Create(Contact collection)
 {
     if (ModelState.IsValid)
     {
         _db.Contacts.Add(collection);
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View();
 }
Esempio n. 2
0
 public ActionResult Edit(int id, Contact collection)
 {
     if (ModelState.IsValid)
     {
         var original = _db.Contacts.Find(collection.Id);
         original.Name = collection.Name;
         original.Birthday = collection.Birthday;
         original.Phone = collection.Phone;
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View();
 }