예제 #1
0
        public ActionResult Add(AddMovieVM model)
        {
            var selectedGenres = model.Genres.Where(x => x.IsChecked).Select(x => x.ID).ToList();

            MovieManager.Add(model.Title, model.ReleaseDate, model.RunningTimeMinutes, selectedGenres);
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Edit(int id)
        {
            var model = new AddMovieVM();

            model.Movie = movieRepo.Get(id);

            return(View(model));
        }
예제 #3
0
        public ActionResult Add()
        {
            var model = new AddMovieVM();

            model.Movie = new Movie();

            return(View(model));
        }
        public IActionResult AddPost(AddMovieVM model)
        {
            if (model.Title == model.Description)
            {
                ModelState.AddModelError("description", "The Description cannot exactly match the Title.");
            }

            if (!ModelState.IsValid)
            {
                return(View("Add", model));
            }

            TempData.Put("AddedMovie", model);

            return(RedirectToAction("Index"));
        }
예제 #5
0
        public ActionResult Add()
        {
            AddMovieVM model             = new AddMovieVM();
            var        allGenres         = GenreManager.GetAll();
            var        checkBoxListItems = new List <CheckBoxListItem>();

            foreach (var genre in allGenres)
            {
                checkBoxListItems.Add(new CheckBoxListItem()
                {
                    ID        = genre.ID,
                    Display   = genre.Name,
                    IsChecked = false
                });
            }
            model.Genres = checkBoxListItems;
            return(View(model));
        }
예제 #6
0
        public ActionResult PostMovie(AddMovieVM newMovie)
        {
            movieRepo.Insert(newMovie.Movie);

            return(RedirectToAction("Index", "Home"));
        }
        public IActionResult Add()
        {
            AddMovieVM model = new AddMovieVM();

            return(View(model));
        }