public ActionResult Add(Movie movieFromView) { if (ModelState.IsValid) { using (var db = new MovieDBContext()) { db.Movies.Add(movieFromView); db.SaveChanges(); } return RedirectToAction("Index"); } return View(movieFromView); }
public ActionResult Delete(Movie movieToDelete) { if (ModelState.IsValid) { using (var db = new MovieDBContext()) { db.Entry(movieToDelete).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } return RedirectToAction("Index"); } return View(movieToDelete); }
public ActionResult Edit(Movie movieToUpdate) { if (ModelState.IsValid) { using (var db = new MovieDBContext()) { db.Entry(movieToUpdate).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("Index"); } return View(movieToUpdate); }
public ActionResult Add() { Movie movie = new Movie(); return View(movie); }