public ActionResult Create(MovieVM movieVM) { try { if (ModelState.IsValid) { using (MoviesReference.MoviesClient service = new MoviesReference.MoviesClient()) { MoviesReference.MovieDto movieDto = new MoviesReference.MovieDto { Title = movieVM.Title, ReleaseDate = movieVM.ReleaseDate, ReleaseCountry = movieVM.ReleaseCountry, Genre = new MoviesReference.GenreDto { Id = movieVM.GenreId } }; service.PostMovie(movieDto); } return(RedirectToAction("Index")); } ViewBag.Genres = LoadDataUtil.LoadGenreData(); return(View()); } catch { ViewBag.Genres = LoadDataUtil.LoadGenreData(); return(View()); } }
// GET: Movies/Edit/5 public ActionResult Edit(int id) { MovieVM movieVM = new MovieVM(); using (MoviesReference.MoviesClient service = new MoviesReference.MoviesClient()) { var movieDto = service.GetMovieByID(id); movieVM = new MovieVM(movieDto); } ViewBag.Genres = LoadDataUtil.LoadGenreData(); return(View(movieVM)); }
// GET: Movies/Create public ActionResult Create() { ViewBag.Genres = LoadDataUtil.LoadGenreData(); return(View()); }