Пример #1
0
 public ActionResult Create(Contact collection)
 {
     try {
         // TODO: Add insert logic here
         _db.Contacts.Add(collection);
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Пример #2
0
        public ActionResult Edit(int id, Contact contact)
        {
            try {
                if (ModelState.IsValid) {
                    var dbContact = _db.Contacts.Find(id);
                    dbContact.Name = contact.Name;
                    dbContact.Phone = contact.Phone;
                    dbContact.Birthday = contact.Birthday;

                    _db.SaveChanges();

                    return RedirectToAction("Index");
                } else {
                    return View();
                }
            }catch {
                return View();
            }
        }