Example #1
0
        public async Task <ActionResult> Index(string genreName, string platformName,
                                               int page = 1, GamesSortOrder sortOrder = GamesSortOrder.ByDateAscending)
        {
            ICollection <GameCardViewModel> games = new List <GameCardViewModel>();

            if (genreName != null)
            {
                games = _mapper.Map <ICollection <GameDTO>, ICollection <GameCardViewModel> >
                            (await _gameService.GetGamesByGenreAsync(genreName));
            }

            if (platformName != null)
            {
                games = _mapper.Map <ICollection <GameDTO>, ICollection <GameCardViewModel> >
                            (await _gameService.GetGamesByPlatformAsync(platformName));
            }

            if (platformName == null && genreName == null)
            {
                games = _mapper.Map <ICollection <GameDTO>, ICollection <GameCardViewModel> >
                            (await _gameService.GetGamesAsync());
            }

            games = SortGames(sortOrder, games);
            GameCardListViewModel gameCardList = await CreateGameCardList(page, games);

            return(View(gameCardList));
        }
Example #2
0
        public static IEnumerable<Game> MostRecent(int howMany, GamesSortOrder sortOrder)
        {
            var games = _games.AsEnumerable()
                .OrderBy(g => g.WhenPlayed)
                .Reverse()
                .Take(howMany);

            if (sortOrder == GamesSortOrder.MostRecentLast)
                return games.Reverse();

            return games;
        }
Example #3
0
        public static IEnumerable <Game> MostRecent(int howMany, GamesSortOrder sortOrder)
        {
            var games = _games.AsEnumerable()
                        .Reverse()
                        .Take(howMany);

            if (sortOrder == GamesSortOrder.MostRecentLast)
            {
                return(games.Reverse());
            }

            return(games);
        }
Example #4
0
        public ICollection <GameCardViewModel> SortGames(GamesSortOrder sortOrder, ICollection <GameCardViewModel> games)
        {
            switch (sortOrder)
            {
            case GamesSortOrder.ByDateDescending:
                return(games.Reverse().ToList());

            case GamesSortOrder.ByRatingAscending:
                return(games.OrderBy(game => game.Rating).ToList());

            case GamesSortOrder.ByRatingDescending:
                return(games.OrderByDescending(game => game.Rating).ToList());

            default:
                return(games);
            }
        }
Example #5
0
File: Games.cs Project: MSIH/ELO
        public static IEnumerable<Game> MostRecent(int howMany, GamesSortOrder sortOrder)
        {
            var games = All.Reverse().Take(howMany);

            return sortOrder == GamesSortOrder.MostRecentLast ? games.Reverse() : games;
        }
Example #6
0
        public static IEnumerable <Game> MostRecent(int howMany, GamesSortOrder sortOrder)
        {
            var games = All.Reverse().Take(howMany);

            return(sortOrder == GamesSortOrder.MostRecentLast ? games.Reverse() : games);
        }