public ActionResult Index(int?sortByOptionId, int?page, string selectedFilterOption) { BoardGamesCollectionPageData boardGamesCollectionPageData = new BoardGamesCollectionPageData(); ViewBag.SelectedFilterOption = selectedFilterOption; boardGamesCollectionPageData.FilterParameters = boardGameFilterService.GetAllFilterParameters(); Dictionary <int, int> filterParametersDict = boardGameFilterService.GetFilterParametersDictByString(selectedFilterOption); boardGameFilterService.SetSelectedFilterOptionInFilterParameters(boardGamesCollectionPageData.FilterParameters, filterParametersDict); ViewBag.CurrentSortOptionId = sortByOptionId; boardGamesCollectionPageData.SortingOptions = boardGameSortService.GetAllSortingOptions(); IQueryable <DAL.Models.BoardGame> boardGamesQuery = boardGamesService.GetAll(); boardGamesQuery = boardGameFilterService.FilterBy(boardGamesQuery, filterParametersDict); boardGamesCollectionPageData.BoardGames = boardGameSortService.SortBy(boardGamesQuery, (BoardGameSortOption)(sortByOptionId ?? 0)) .Select(bg => new BoardGame() { BoardGameId = bg.BoardGameId, Name = bg.Name, Description = bg.Description, Content = bg.Content, Image = bg.Image, GameTimeInMinutes = bg.GameTimeInMinutes, MinPlayerCount = bg.MinPlayerCount, MaxPlayerCount = bg.MaxPlayerCount, MinimumAge = bg.MinimumAge, BoardGameCategoryName = bg.BoardGameCategory.Name, BoardGameStateName = bg.BoardGameState.Name, BoardGamePublisherName = bg.BoardGamePublisher.Name, Quantity = bg.Quantity, RentalCostPerDay = bg.RentalCostPerDay, ImagePath = bg.ImagePath, DetailsImagePath = bg.DetailsImagePath }) .ToPagedList(page ?? 1, 3); return(View(boardGamesCollectionPageData)); }
// GET: BoardGamesCollection public ActionResult BoardGamesCollection(int?page) { IQueryable <DAL.Models.BoardGame> boardGamesQuery = boardGamesService.GetAll(); return(userTypeService.Authorize(() => View(boardGameSortService.SortBy(boardGamesQuery, BLL.Enums.BoardGameSortOption.SortAscendingByName).Select(bg => new BoardGame() { BoardGameId = bg.BoardGameId, Name = bg.Name, Description = bg.Description, Content = bg.Content, Image = bg.Image, GameTimeInMinutes = bg.GameTimeInMinutes, MinPlayerCount = bg.MinPlayerCount, MaxPlayerCount = bg.MaxPlayerCount, MinimumAge = bg.MinimumAge, BoardGameStateName = bg.BoardGameState.Name, BoardGamePublisherName = bg.BoardGamePublisher.Name, BoardGameCategoryName = bg.BoardGameCategory.Name, ImagePath = bg.ImagePath, DetailsImagePath = bg.DetailsImagePath }).ToPagedList(page ?? 1, 5)), UserType.Administrator, UserType.Employee)); }