예제 #1
0
        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());
            }
        }
예제 #2
0
        // 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));
        }
예제 #3
0
        // GET: Movies/Create
        public ActionResult Create()
        {
            ViewBag.Genres = LoadDataUtil.LoadGenreData();

            return(View());
        }