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()); } }
public static SelectList LoadGenreData() { using (GenresReference.GenresClient service = new GenresReference.GenresClient()) { return(new SelectList(service.GetGenres(), "Id", "Name")); } }
// GET: Movies/Create public ActionResult Create() { using (GenresReference.GenresClient service = new GenresReference.GenresClient()) { ViewBag.Genres = new SelectList(service.GetGenres(), "Id", "Name"); } return(View()); }
// GET: Movies/Edit/5 public ActionResult Edit(int id) { MovieVM movieVM = new MovieVM(); using (MoviesReference.MoviesClient service = new MoviesReference.MoviesClient()) { var movie = service.GetMovieByID(id); movieVM = new MovieVM { Title = movie.Title, ReleaseDate = movie.ReleaseDate, ReleaseCountry = movie.ReleaseCountry, GenreId = movie.Genre.Id }; } using (GenresReference.GenresClient service = new GenresReference.GenresClient()) { ViewBag.Genres = new SelectList(service.GetGenres(), "Id", "Name"); } return(View(movieVM)); }