public IActionResult List(string?orderBy, int?value)
        {
            var viewModel = new ShowGenreCategoryViewModel();

            viewModel.Categories = CategoryRepository.GetAll().ToList();
            viewModel.Genres     = GenreRepository.GetAll().ToList();

            if (orderBy == null || value == null)
            {
                viewModel.Shows = ShowRepository.GetAll().ToList();
                return(View(viewModel));
            }
            else
            {
                if (orderBy == "Genre")
                {
                    var shows = ShowRepository.GetAll();
                    viewModel.Shows = shows.Where(i => i.GenreId == value).ToList();
                    return(View(viewModel));
                }
                else if (orderBy == "Category")
                {
                    var shows = ShowRepository.GetAll();
                    viewModel.Shows = shows.Where(i => i.CategoryId == value).ToList();
                    return(View(viewModel));
                }
                return(View(viewModel));
            }
        }
示例#2
0
        public Task <IEnumerable <Show> > GetPagedShows(int page, int itemsPerPage)
        {
            var pagedShows = _showRepository
                             .GetAll()
                             .Skip(page * itemsPerPage)
                             .Take(itemsPerPage);

            return(Task.FromResult(pagedShows));
        }