public ActionResult Delete(int id, Contact contact) { try { using (var db = new ContactEntities()) { db.Entry(db.Contacts.Find(id)).State = EntityState.Deleted; db.SaveChanges(); return RedirectToAction("Index"); } } catch { return View(); } }
public ActionResult Create(Contact contact) { try { using (var db = new ContactEntities()) { contact.Text = HttpUtility.UrlDecode(contact.Text, System.Text.Encoding.Default); db.Contacts.Add(contact); db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, Contact contact) { try { using (var db = new ContactEntities()) { contact.Text = HttpUtility.UrlDecode(contact.Text, System.Text.Encoding.Default); db.Entry(contact).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } } catch { return View(); } }