Пример #1
0
        public IActionResult TVShowsIndex(int page = 1)
        {
            var viewModel = new AllTVShowsViewModel();

            if (viewModel == null)
            {
                return(this.NotFound());
            }

            viewModel.Genres  = this.tvshowsService.GetAllGenres <GenreViewModel>();
            viewModel.TVShows = this.tvshowsService.GetTVShowsForPage <TVShowViewModel>(ItemsPerPage, (page - 1) * ItemsPerPage);

            var count = this.tvshowsService.GetTVShowsCount();

            viewModel.PagesCount = (int)Math.Ceiling((double)count / ItemsPerPage);

            if (viewModel.PagesCount == 0)
            {
                viewModel.PagesCount = 1;
            }

            viewModel.CurrentPage = page;

            return(this.View(viewModel));
        }
Пример #2
0
        public IActionResult TVShowsByGenre(string genre)
        {
            var viewModel = new AllTVShowsViewModel
            {
                TVShows = this.tvshowsService.GetAllByGenre <TVShowViewModel>(genre),
                Genres  = this.tvshowsService.GetAllGenres <GenreViewModel>(),
            };

            if (viewModel == null)
            {
                return(this.NotFound());
            }

            return(this.View(viewModel));
        }