public ActionResult Delete(Actor actorToDelete) { if (ModelState.IsValid) { using (var db = new MovieDBContext()) { db.Entry(actorToDelete).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } return RedirectToAction("Index"); } return View(actorToDelete); }
public ActionResult Add(Actor actorFromView) { if (ModelState.IsValid) { using (var db = new MovieDBContext()) { db.Actors.Add(actorFromView); db.SaveChanges(); } return RedirectToAction("Index"); } return View(actorFromView); }
public ActionResult Edit(Actor actorToUpdate) { if (ModelState.IsValid) { using (var db = new MovieDBContext()) { db.Entry(actorToUpdate).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("Index"); } return View(actorToUpdate); }