public ActionResult Create(Movie movie) { if (ModelState.IsValid) { movieRepository.InsertOrUpdate(movie); movieRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
public void InsertOrUpdate(Movie movie) { if (movie.Id == default(long)) { // New entity context.Movies.Add(movie); } else { // Existing entity context.Entry(movie).State = EntityState.Modified; } }
public ActionResult Edit(Movie movieToEdit) { try { // TODO: Add update logic here return RedirectToAction("Index"); } catch { return View(); } }