public async Task <Dictionary <string, PlayerGameStats> > GetGameStatsDictionaryAsync(IDictionary <string, Player> roster, FantasyMatchupWeeks matchupWeek) { Dictionary <string, PlayerGameStats> statsDictionary = new Dictionary <string, PlayerGameStats> { { "PG1", null }, { "PG2", null }, { "SG1", null }, { "SG2", null }, { "SF1", null }, { "SF2", null }, { "PF1", null }, { "PF2", null }, { "C", null }, }; foreach (KeyValuePair <string, Player> player in roster) { if (player.Value != null) { var gameTonight = await HasGameTonightAsync(matchupWeek, player.Value.TeamID); if (gameTonight != null) { var stats = await _playerGameStatsService.GetPlayerGameStatsByGameAsync(player.Value.PlayerID, gameTonight.GameID); if (stats != null) { statsDictionary[player.Key] = stats;; } } } } return(statsDictionary); }
// GET: Players/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var viewModel = new PlayerDetailsViewModel() { Player = await _playersService.GetPlayerAsync(id.Value) }; if (viewModel.Player == null) { return(NotFound()); } viewModel.Games = await _gamesService.GetFinalGamesByTeamAsync(viewModel.Player.TeamID); viewModel.GameLogs = new List <PlayerGameStats>(); foreach (Game g in viewModel.Games) { var log = _playerGameStatsService.GetPlayerGameStatsByGameAsync(viewModel.Player.PlayerID, g.GameID);; viewModel.GameLogs.Add(await log); } return(View(viewModel)); }