/// <summary> /// Sort Games with all data /// </summary> /// <param name="games"></param> /// <param name="pageNumber"></param> /// <param name="sortOrder"></param> /// <returns></returns> public async Task <GamesIndexData> SortGamesIndex(IQueryable <Game> games, int?pageNumber, string sortOrder) { GamesIndexData gamesAllData = new GamesIndexData(); games = _gameServices.SortGames(games, sortOrder); int pageSize = 3; PaginatedList <Game> pl = await PaginatedList <Game> .CreateAsync(games, pageNumber ?? 1, pageSize); var gamesTmp = from g in games where pl.Contains(g) select g; gamesAllData = await GetGamesAndCategories(gamesTmp); gamesAllData = _gameServices.SortGames(gamesAllData, sortOrder); gamesAllData.PageIndex = pl.PageIndex; gamesAllData.TotalPages = pl.TotalPages; return(gamesAllData); }