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()); } }
public ActionResult Create(MovieVM movieVM) { try { 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); } using (GenresReference.GenresClient service = new GenresReference.GenresClient()) { ViewBag.Genres = new SelectList(service.GetGenres(), "Id", "Name"); } return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Movies/Delete/5 public ActionResult Delete(int id) { MovieVM movieVM = new MovieVM(); using (MoviesReference.MoviesClient service = new MoviesReference.MoviesClient()) { MoviesReference.MovieDto movieDto = service.GetMovieByID(id); movieVM = new MovieVM { Id = movieDto.Id, Title = movieDto.Title, ReleaseDate = movieDto.ReleaseDate, ReleaseCountry = movieDto.ReleaseCountry, GenreId = movieDto.Genre.Id, GenreVM = new GenreVM { Id = movieDto.Genre.Id, Name = movieDto.Genre.Name } }; } return(View(movieVM)); }
// GET: Movies/Delete/5 public ActionResult Delete(int id) { MovieVM movieVM = new MovieVM(); using (MoviesReference.MoviesClient service = new MoviesReference.MoviesClient()) { MoviesReference.MovieDto movieDto = service.GetMovieByID(id); movieVM = new MovieVM(movieDto); } return(View(movieVM)); }