예제 #1
0
        public ActionResult Create()
        {
            MovieViewModel viewModel = new MovieViewModel();

            viewModel.Movie = new Movie();
            using (GenreManager genreManager = new GenreManager())
            {
                viewModel.PossibleGenres = genreManager.GetAll();
            }
            using (RatingManager ratingManager = new RatingManager())
            {
                viewModel.PossibleRatings = ratingManager.GetAll();
            }
            using (DirectorManager directorManager = new DirectorManager())
            {
                viewModel.PossibleDirectors = directorManager.GetAll();
            }
            using (FormatManager formatManager = new FormatManager())
            {
                viewModel.PossibleFormats = formatManager.GetAll();
            }

            return(View(viewModel));
        }
        public void Get_All_Returns_More_Than_One()
        {
            var all = manager.GetAll();

            Assert.IsTrue(all.Count > 1);
        }
예제 #3
0
        public ActionResult Edit(int id)
        {
            Movie movie = new Movie();

            using (manager = new MovieManager())
            {
                movie = manager.GetById(id);
            }
            if (movie == null)
            {
                return(HttpNotFound());
            }
            else
            {
                MovieViewModel vm = new MovieViewModel();
                using (GenreManager genreManager = new GenreManager()) { vm.PossibleGenres = genreManager.GetAll(); }
                using (RatingManager ratingManager = new RatingManager()) { vm.PossibleRatings = ratingManager.GetAll(); }
                using (DirectorManager directorManager = new DirectorManager()) { vm.PossibleDirectors = directorManager.GetAll(); }
                using (FormatManager formatManager = new FormatManager()) { vm.PossibleFormats = formatManager.GetAll(); }
                //vm.MovieId = movie.Id;
                vm.Movie            = movie;
                vm.MovieDescription = movie.Description;
                vm.MovieCost        = movie.Cost;
                vm.MovieTitle       = movie.Title;
                vm.ImagePath        = movie.ImagePath;

                vm.CurrentGenres = new List <int>();
                foreach (var a in movie.Genres)
                {
                    vm.CurrentGenres.Add(a.Id);
                }
                return(View(vm));
            }
        }