예제 #1
0
        public ActionResult GetPage(int?page)
        {
            int pageSize = VariableUtils.pageSearchMovie;

            int pageNumber = (page ?? 1);

            var listTrailer          = _trailerService.GetAll();
            var listModel            = new List <TrailerMovieViewModel>();
            var listTrailerViewModel = AutoMapper.Mapper.Map <ICollection <TrailerViewModel> >(listTrailer);

            foreach (var item in listTrailerViewModel)
            {
                var model = new TrailerMovieViewModel()
                {
                    TrailerViewModel = item
                };

                if (item.MovieId != null)
                {
                    var movie          = _moviesService.Find(item.MovieId);
                    var movieViewModel = AutoMapper.Mapper.Map <MoviesViewModel>(movie);
                    model.MoviesViewModel = movieViewModel;
                }

                listModel.Add(model);
            }

            return(PartialView("_PartialViewTrailer",
                               listModel.ToPagedList(pageNumber, pageSize)));
        }
        public ManagerTrailersController(ITrailerService trailerService, IMoviesService moviesService)
        {
            _trailerService = trailerService;
            _moviesService  = moviesService;

            var trailers = _trailerService.GetAll();

            if (trailers != null)
            {
                var trailerViewModels = Mapper.Map <IEnumerable <TrailerViewModel> >(trailers);
                foreach (var trailer in trailerViewModels)
                {
                    var movie          = _moviesService.Find(trailer.MovieId);
                    var movieViewModel = Mapper.Map <MoviesViewModel>(movie);
                    trailer.MoviesViewModel = movieViewModel;
                }
                _listTrailerViewModels = trailerViewModels.ToList();
            }
        }
예제 #3
0
 public IEnumerable <TrailerViewModel> Get()
 {
     return(_trailerService.GetAll());
 }