public ActionResult Update(int id) { using(var db = new PersonContext()) { return View(db.Persons.Find(id)); } }
public ActionResult DeleteConfirm(int id) { using(var db = new PersonContext()) { return View(db.Persons.Find(id)); } }
public ActionResult List() { using (var db = new PersonContext()) { var persons = from p in db.Persons select p; return Json(persons.ToList(), JsonRequestBehavior.AllowGet); } }
public ActionResult Index() { using(var db = new PersonContext()) { var persons = from p in db.Persons select p; return View(persons.ToList()); } }
public ActionResult Update(Person person) { using(var db = new PersonContext()) { db.Persons.Attach(person); db.Entry(person).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Delete(int id) { using(var db = new PersonContext()) { var p = db.Persons.Find(id); db.Entry(p).State = EntityState.Deleted; db.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Insert(Person person) { if (ModelState.IsValid) { using(var db = new PersonContext()) { db.Persons.Add(person); db.SaveChanges(); } return RedirectToAction("Index"); } return View(); }