public ActionResult Create(Movie movie) { if (ModelState.IsValid) { movie.DateAdded = DateTime.UtcNow; MoviesDb.Add(movie); return(RedirectToAction("Index")); } ViewBag.GenreId = new SelectList(GenresDb.GetAll(), "Id", "Name", movie.GenreId); return(View(movie)); }
public ActionResult Save(Movie movie) { if (!ModelState.IsValid) { return(RedirectToAction("Index", "Movies")); } if (movie.Id == 0) { MoviesDb.Add(movie); } else { var movieInDb = MoviesDb.GetById(movie.Id); // update properties movieInDb.Name = movie.Name; MoviesDb.Update(movieInDb); } return(RedirectToAction("Index", "Movies")); }