public ActionResult Edit(MoviesModel model, int Id) { if (!ModelState.IsValid) { var movieModel = new MoviesModel(); movieModel.GenreList = GetGenreList(); model.RatingList = GetRatingList(); movieModel.Viewed = model.Viewed; movieModel.MovieID = Id; return View(movieModel); } var movie = new Movy(); movie.Title = model.Title; movie.ImdbLink = model.ImdbLink; movie.description = model.Description; movie.Director = model.Director; movie.Genre = model.Genre; movie.viewed = model.Viewed; movie.Rating = model.Rating; MovieRepository.UpdateMovie(movie, Id); //clears the cache so the movie will be updated in the list CacheHelper.RemoveCache("Movies"); return RedirectToAction("Index", "Home"); }
public ActionResult Add(MoviesModel model) { if (!ModelState.IsValid) { var movieModel = new MoviesModel(); movieModel.GenreList = GetGenreList(); model.RatingList = GetRatingList(); movieModel.Viewed = DateTime.Now.Date; return View(movieModel); } var movie = new Movy(); movie.Title = model.Title; movie.ImdbLink = model.ImdbLink; movie.description = model.Description; movie.Director = model.Director; movie.Genre = model.Genre; movie.Rating = model.Rating; movie.viewed = model.Viewed; MovieRepository.AddMovie(movie); //clears the cache so the new movie will be in the lists CacheHelper.RemoveCache("Movies"); return RedirectToAction("Index","Home"); }