Пример #1
0
        public async Task <ActionResult> Index(int?page)
        {
            var liveLeagueGames = await db.GetLiveLeagueGamesAsync();

            var liveLeagueGameViewModels = liveLeagueGames
                                           .Select(x => new LiveLeagueGameListItemViewModel()
            {
                MatchId           = x.MatchId,
                BestOf            = x.BestOf,
                DireKillCount     = x.DireKillCount,
                DireTeamName      = x.DireTeamName,
                ElapsedTime       = x.ElapsedTimeDisplay,
                LeagueLogoPath    = x.LeagueLogoPath,
                LeagueName        = x.LeagueName,
                RadiantKillCount  = x.RadiantKillCount,
                RadiantTeamName   = x.RadiantTeamName,
                RadiantSeriesWins = x.RadiantSeriesWins,
                DireSeriesWins    = x.DireSeriesWins,
                SpectatorCount    = x.SpectatorCount,
                DireTeamLogo      = x.DireTeamLogo,
                LeagueTier        = x.LeagueTier,
                RadiantTeamLogo   = x.RadiantTeamLogo,
                DirePlayers       = x.Players
                                    .Where(y => y.Team == 1)
                                    .Select(y => new LiveLeagueGamePlayerViewModel()
                {
                    HeroId             = y.HeroId,
                    HeroName           = y.HeroName,
                    HeroAvatarFilePath = y.HeroAvatarImageFilePath,
                    PlayerName         = y.Name,
                    AccountId          = y.AccountId,
                    NetWorth           = y.NetWorth,
                    Level = y.Level,
                    MinimapIconFilePath = y.GetMinimapIconFilePath()
                })
                                    .ToList()
                                    .AsReadOnly(),
                RadiantPlayers = x.Players
                                 .Where(y => y.Team == 0)
                                 .Select(y => new LiveLeagueGamePlayerViewModel()
                {
                    HeroId             = y.HeroId,
                    HeroName           = y.HeroName,
                    HeroAvatarFilePath = y.HeroAvatarImageFilePath,
                    PlayerName         = y.Name,
                    AccountId          = y.AccountId,
                    NetWorth           = y.NetWorth,
                    Level = y.Level,
                    MinimapIconFilePath = y.GetMinimapIconFilePath()
                })
                                 .ToList()
                                 .AsReadOnly()
            })
                                           .ToPagedList(page ?? 1, 25);

            return(View(liveLeagueGameViewModels));
        }
Пример #2
0
        private async Task <LiveLeagueGameOverviewViewModel> GetTopLiveLeagueGameAsync()
        {
            var liveLeagueGames = await db.GetLiveLeagueGamesAsync(1);

            var liveLeagueGameViewModels = liveLeagueGames
                                           .Select(x => new LiveLeagueGameOverviewViewModel()
            {
                MatchId            = x.MatchId,
                BestOf             = x.BestOf,
                DireKillCount      = x.DireKillCount,
                DireTeamLogo       = x.DireTeamLogo,
                DireTeamName       = x.DireTeamName,
                ElapsedTime        = x.ElapsedTimeDisplay,
                GameNumber         = x.GameNumber,
                LeagueLogoPath     = x.LeagueLogoPath,
                LeagueName         = x.LeagueName,
                RadiantKillCount   = x.RadiantKillCount,
                RadiantTeamLogo    = x.RadiantTeamLogo,
                RadiantTeamName    = x.RadiantTeamName,
                RadiantSeriesWins  = x.RadiantSeriesWins,
                DireSeriesWins     = x.DireSeriesWins,
                SpectatorCount     = x.SpectatorCount,
                RadiantTowerStates = x.RadiantTowerStates,
                DireTowerStates    = x.DireTowerStates,
                DirePlayers        = x.Players
                                     .Where(y => y.Team == 1)
                                     .Select(y => new LiveLeagueGamePlayerViewModel()
                {
                    HeroName            = y.HeroName,
                    HeroAvatarFilePath  = y.HeroAvatarImageFilePath,
                    PlayerName          = y.Name,
                    DeathCount          = y.DeathCount,
                    KillCount           = y.KillCount,
                    AssistCount         = y.AssistCount,
                    PositionX           = y.PositionX,
                    PositionY           = y.PositionY,
                    PositionXPercent    = y.PositionX.GetPercentOfPositionValue(),
                    PositionYPercent    = y.PositionY.GetPercentOfPositionValue(),
                    MinimapIconFilePath = y.GetMinimapIconFilePath()
                })
                                     .ToList()
                                     .AsReadOnly(),
                RadiantPlayers = x.Players
                                 .Where(y => y.Team == 0)
                                 .Select(y => new LiveLeagueGamePlayerViewModel()
                {
                    HeroName            = y.HeroName,
                    HeroAvatarFilePath  = y.HeroAvatarImageFilePath,
                    PlayerName          = y.Name,
                    DeathCount          = y.DeathCount,
                    KillCount           = y.KillCount,
                    AssistCount         = y.AssistCount,
                    PositionX           = y.PositionX,
                    PositionY           = y.PositionY,
                    PositionXPercent    = y.PositionX.GetPercentOfPositionValue(),
                    PositionYPercent    = y.PositionY.GetPercentOfPositionValue(),
                    MinimapIconFilePath = y.GetMinimapIconFilePath()
                })
                                 .ToList()
                                 .AsReadOnly()
            })
                                           .ToList()
                                           .AsReadOnly();

            if (liveLeagueGameViewModels != null && liveLeagueGameViewModels.Count > 0)
            {
                return(liveLeagueGameViewModels[0]);
            }
            else
            {
                return(null);
            }
        }