Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 public ActionResult Create()
 {
     MovieViewModel movieViewModel = new MovieViewModel();
     movieViewModel.genreList = Facade.GetGenreGateway().ReadAll().ToList();
     return View(movieViewModel);
 }