示例#1
0
        public virtual PlayerDetails GetPlayerDetails(int playerId, int numberOfRecentGamesToRetrieve)
        {
            var returnPlayer = _dataContext.GetQueryable <Player>()
                               .Include(player => player.Nemesis)
                               .Include(player => player.Nemesis.NemesisPlayer)
                               .Include(player => player.PreviousNemesis)
                               .Include(player => player.PreviousNemesis.NemesisPlayer)
                               .Include(player => player.GamingGroup)
                               .SingleOrDefault(player => player.Id == playerId);

            ValidatePlayerWasFound(playerId, returnPlayer);

            var playerStatistics = GetPlayerStatistics(playerId);

            var playerGameResults = GetPlayerGameResultsWithPlayedGameAndGameDefinition(playerId, numberOfRecentGamesToRetrieve);

            var minions = GetMinions(returnPlayer.Id);

            var playerGameSummaries = _playerRepository.GetPlayerGameSummaries(playerId, _dataContext);

            var championedGames = GetChampionedGames(returnPlayer.Id);

            var formerChampionedGames = GetFormerChampionedGames(returnPlayer.Id);

            var longestWinningStreak = _playerRepository.GetLongestWinningStreak(playerId, _dataContext);

            var query = new GetRecentPlayerAchievementsUnlockedQuery
            {
                PlayerId = playerId,
                Page     = 1,
                PageSize = int.MaxValue
            };
            var recentAchievementsUnlocked = _recentPlayerAchievementsUnlockedRetriever.GetResults(query);

            var playerVersusPlayerStatistics = _playerRepository.GetPlayerVersusPlayersStatistics(playerId, _dataContext);

            var playerDetails = new PlayerDetails
            {
                Active            = returnPlayer.Active,
                ApplicationUserId = returnPlayer.ApplicationUserId,
                Id                            = returnPlayer.Id,
                Name                          = returnPlayer.Name,
                GamingGroupId                 = returnPlayer.GamingGroupId,
                GamingGroupName               = returnPlayer.GamingGroup.Name,
                PlayerGameResults             = playerGameResults,
                PlayerStats                   = playerStatistics,
                CurrentNemesis                = returnPlayer.Nemesis ?? new NullNemesis(),
                PreviousNemesis               = returnPlayer.PreviousNemesis ?? new NullNemesis(),
                Minions                       = minions,
                PlayerGameSummaries           = playerGameSummaries,
                ChampionedGames               = championedGames,
                PlayerVersusPlayersStatistics = playerVersusPlayerStatistics,
                FormerChampionedGames         = formerChampionedGames,
                LongestWinningStreak          = longestWinningStreak,
                NemePointsSummary             = playerStatistics.NemePointsSummary,
                Achievements                  = recentAchievementsUnlocked.ToList()
            };

            return(playerDetails);
        }
示例#2
0
        public IPagedList <PlayerAchievementWinner> GetResults(GetRecentPlayerAchievementsUnlockedQuery query)
        {
            var playerAchievementWinnersQueryable =
                _dataContext.GetQueryable <PlayerAchievement>()
                .Where(x => query.PlayerId == null || x.PlayerId == query.PlayerId.Value)
                .Select(x => new PlayerAchievementWinner
            {
                AchievementId             = x.AchievementId,
                AchievementLastUpdateDate = x.LastUpdatedDate,
                AchievementLevel          = x.AchievementLevel,
                GamingGroupId             = x.Player.GamingGroupId,
                GamingGroupName           = x.Player.GamingGroup.Name,
                PlayerId        = x.PlayerId,
                PlayerName      = x.Player.Name,
                UserId          = x.Player.ApplicationUserId,
                DateCreated     = x.DateCreated,
                LastUpdatedDate = x.LastUpdatedDate
            })
                .OrderByDescending(p => p.AchievementLastUpdateDate);

            var pagedList = playerAchievementWinnersQueryable.ToPagedList(query.Page, query.PageSize);

            var distinctAchievements = pagedList.GroupBy(x => x.AchievementId).ToDictionary(x => x.Key, y => _achievementRetriever.GetAchievement(y.Key));

            foreach (var playerAchievementWinner in pagedList)
            {
                var achievement = distinctAchievements[playerAchievementWinner.AchievementId];
                playerAchievementWinner.IconClass       = achievement.IconClass;
                playerAchievementWinner.AchievementName = achievement.Name;
                playerAchievementWinner.Description     = achievement.Description;
            }

            return(pagedList);
        }
        public override IPagedList <PlayerAchievement> GetFromSource(GetRecentPlayerAchievementsUnlockedQuery inputParameter)
        {
            var playerAchievements =
                _dataContext.GetQueryable <PlayerAchievement>()
                .Include(pa => pa.Player)
                .Include(pa => pa.Player.GamingGroup)
                .OrderByDescending(p => p.LastUpdatedDate)
            ;

            return(playerAchievements.ToPagedList(inputParameter.Page, inputParameter.PageSize));
        }
        public RecentGamingGroupChanges GetRecentChanges(int gamingGroupId, BasicDateRangeFilter dateFilter)
        {
            var recentGamingGroupChanges = new RecentGamingGroupChanges();
            var query = new GetRecentPlayerAchievementsUnlockedQuery
            {
                GamingGroupId      = gamingGroupId,
                IncludeOnlyOnePage = true,
                PageSize           = 10
            };

            recentGamingGroupChanges.RecentAchievements = _recentPlayerAchievementsUnlockedRetriever.GetResults(query);

            return(recentGamingGroupChanges);
        }
示例#5
0
 protected bool Equals(GetRecentPlayerAchievementsUnlockedQuery other)
 {
     return(base.Equals(other) && PlayerId == other.PlayerId);
 }