public async Task <decimal[]> CalculateScoreAsync(FantasyMatchup matchup) { var matchupWeek = await _fantasyMatchupsWeeksService.GetFantasyMatchupWeekByLeagueAsync(matchup.FantasyLeagueID, matchup.Week); decimal homeScore = 0; decimal awayScore = 0; if (matchupWeek != null) { var home = await _playerMyTeamService.GetRosterAsync(matchup.HomeTeamID.Value); if (home.Any() && home != null) { List <PlayerGameStats> homeStats = await GetGameStatsListAsync(home, matchupWeek); if (homeStats != null) { homeScore = homeStats.Sum(x => x.FantasyPoints); } } var away = await _playerMyTeamService.GetRosterAsync(matchup.AwayTeamID.Value); if (away.Any() && away != null) { List <PlayerGameStats> awayStats = await GetGameStatsListAsync(away, matchupWeek); if (awayStats != null) { awayScore = awayStats.Sum(x => x.FantasyPoints); } } } return(new decimal[] { homeScore, awayScore }); }
// GET: FantasyMatchups/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var viewModel = new FantasyMatchupDetailsViewModel { FantasyMatchup = await _fantasyMatchupService.GetMatchupByIDAsync(id.Value) }; var matchupWeek = await _fantasyMatchupsWeeksService.GetFantasyMatchupWeekByLeagueAsync(viewModel.FantasyMatchup.FantasyLeagueID, viewModel.FantasyMatchup.Week); viewModel.Date = matchupWeek.Date; return(View(viewModel)); }