public ActionResult AddMovie() { ViewBag.Message = "Add New Movie:"; Movie model = new Movie(); return View(model); }
public ActionResult AddMovie(Movie model) { using (ApplicationDbContext db = new ApplicationDbContext()) { Movie NewMovie = new Movie() { MovieId = model.MovieId, Title = model.Title, Year = model.Year, Genre = model.Genre, Rating = model.Rating }; db.Movies.Add(NewMovie); db.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult EditMovie(Movie model) { using (ApplicationDbContext db = new ApplicationDbContext()) { Movie movie = db.Movies.FirstOrDefault(x => x.MovieId == model.MovieId); movie.Title = model.Title; movie.Year = model.Year; movie.Genre = model.Genre; movie.Rating = model.Rating; db.SaveChanges(); } return RedirectToAction("Details", new { id = model.MovieId }); }