private static void OutputRunsByTeamGrid(TeamRunsCollection teamRunsCollection) { Console.WriteLine(""); var dateOfRunsForTeams = teamRunsCollection.ComputeDateOfRunsForTeams(); foreach (var dateOfRunsForTeam in dateOfRunsForTeams) { Console.WriteLine($"{dateOfRunsForTeam.TeamName},{string.Join(", ", dateOfRunsForTeam.DatesOfRuns)}"); } }
private static void OutputRemainingRunsByTeam(TeamRunsCollection teamRunsCollection) { Console.WriteLine(""); var remainingRuns = teamRunsCollection.ComputeRemainingRunsByTeam(); foreach (var rr in remainingRuns.OrderBy(x => x.RemainingRuns.Count)) { Console.WriteLine($"{rr.TeamName.PadRight(12, ' ')} \t {rr.RemainingRuns.Count} ({string.Join(", ", rr.RemainingRuns)})"); } }
private async Task <TeamRunsCollection> UpdateTeamRunsCollectionForDate(TeamRunsCollection teamRunsCollection, DateTime forDate) { try { var forDateYear = forDate.Year; var requestOptions = new RequestOptions() { ForDate = FormatForDateForApi(forDate) }; var scoreboardResponseDto = await _mySportsFeedsClient.ScoreboardDataRetriever.Get(forDateYear, SeasonType.Regular, requestOptions); if (scoreboardResponseDto == null) { return(teamRunsCollection); } if (scoreboardResponseDto.Scoreboard.GameScore == null) { return(teamRunsCollection); } Console.WriteLine($"Processing {scoreboardResponseDto.Scoreboard.GameScore.Count} games for {forDate.ToShortDateString()}"); foreach (var gameScore in scoreboardResponseDto.Scoreboard.GameScore) { if (gameScore.IsCompleted == "false") { continue; } var homeTeamName = gameScore.Game.HomeTeam.Name; var homeTeamScore = gameScore.HomeScore; teamRunsCollection.AddRunsForTeamByDate(forDate, homeTeamName, homeTeamScore); var awayTeamName = gameScore.Game.AwayTeam.Name; var awayTeamScore = gameScore.AwayScore; teamRunsCollection.AddRunsForTeamByDate(forDate, awayTeamName, awayTeamScore); } return(teamRunsCollection); } catch (Exception ex) { Console.WriteLine(ex.InnerException); throw ex; } }
public async Task <TeamRunsCollection> ProcessDailyGamesForRound(DateTime roundStartDate) { var teamRunsCollection = new TeamRunsCollection(); var currentDate = roundStartDate; Console.WriteLine($"=> Start processing the daily games at {DateTime.Now}"); while (currentDate <= DateTime.Now) { await UpdateTeamRunsCollectionForDate(teamRunsCollection, currentDate); if (teamRunsCollection.RoundIsOver) { break; } currentDate = currentDate.AddDays(1); } Console.WriteLine($"=> Completed processing the daily games at {DateTime.Now}"); return(teamRunsCollection); }