public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } MovieViewModel movieViewModel = new MovieViewModel(); movieViewModel.genreList = Facade.GetGenreGateway().ReadAll().ToList(); movieViewModel.movie = Facade.GetMovieGateway().Read((int)id); return View(movieViewModel); }
public ActionResult Create(Movie movie, string[] idGenre) { if (ModelState.IsValid) { if (idGenre != null) { movie.genres = new List<Genres>(); foreach (String genreId in idGenre) { int id = int.Parse(genreId); Genres genre = new Genres() { id = id }; movie.genres.Add(genre); } } Facade.GetMovieGateway().Create(movie); return RedirectToAction("Index"); } MovieViewModel movieViewModel = new MovieViewModel(); movieViewModel.genreList = Facade.GetGenreGateway().ReadAll().ToList(); movieViewModel.movie = movie; return View(movieViewModel); }
public ActionResult Edit(MovieShopDAL.Movie movie, string[] idGenre) { if (ModelState.IsValid) { if (idGenre != null) { movie.genres.Clear(); foreach (string genreId in idGenre) { movie.genres.Add(new Genres() { id = int.Parse(genreId) }); } } Facade.GetMovieGateway().Update(movie); return RedirectToAction("Index"); } MovieViewModel movieViewModel = new MovieViewModel(); movieViewModel.genreList = Facade.GetGenreGateway().ReadAll().ToList(); movieViewModel.movie = movie; return View(movieViewModel); }
public ActionResult Create() { MovieViewModel movieViewModel = new MovieViewModel(); movieViewModel.genreList = Facade.GetGenreGateway().ReadAll().ToList(); return View(movieViewModel); }