Beispiel #1
0
        // GET: /Movies/
        public ActionResult Index(int? page)
        {
            var movies = movieRepo.GetAllMovies().OrderBy(m => m.title);
            var pagedMovies = new PaginatedList<Movie>(movies, page ?? 0, _pageSize);

            ViewData["FilterData"] = new MovieFormViewModel();

            ViewData["YearMin"] = movies.OrderBy(m => m.year).First<Movie>().year;
            ViewData["YearMax"] = movies.OrderByDescending(m => m.year).First<Movie>().year;
            ViewData["LengthMin"] = movies.OrderBy(m => m.length).First<Movie>().length;
            ViewData["LengthMax"] = movies.OrderByDescending(m => m.length).First<Movie>().length;

            return View(pagedMovies);
        }
Beispiel #2
0
        public ActionResult Edit(int id, FormCollection formValues)
        {
            Movie movie = movieRepo.GetMovie(id);
            MovieFormViewModel viewMovie = new MovieFormViewModel(movie);

            try
            {
                UpdateModel(viewMovie);
                movieRepo.Save();

                return RedirectToAction("Details", new { id = movie.movie_id });
            }
            catch
            {
                ModelState.AddRuleViolations(movie.GetRuleViolations());
                return View(new MovieFormViewModel(movie));
            }
        }