public ActionResult Create(Movie movie) { if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return RedirectToAction("Index"); } return View(movie); }
public ActionResult Edit(Movie movie) { if (ModelState.IsValid) { // Get original movie var originalMovie = db.Movies.Find(movie.Id); // Update properties originalMovie.Title = movie.Title; originalMovie.Director = movie.Director; // Save changes db.SaveChanges(); return RedirectToAction("Index"); } return View(movie); }