private void UpdateResult(string fixtureId, int season) { int homeWin, awayWin, tie; homeWin = awayWin = tie = 0; var fixture = _fixturesService.Get(fixtureId); var homeStanding = _standingsService.GetTeamStandings(fixture.HomeTeamId, season); var awayStanding = _standingsService.GetTeamStandings(fixture.AwayTeamId, season); if (fixture.HomeScore > fixture.AwayScore) { homeWin = 1; _standingsService.UpdateStreak(homeStanding.Id, 'W'); _standingsService.UpdateLastFive(homeStanding.Id, 'W'); _standingsService.UpdateStreak(awayStanding.Id, 'L'); _standingsService.UpdateLastFive(awayStanding.Id, 'L'); } else if (fixture.AwayScore > fixture.HomeScore) { awayWin = 1; _standingsService.UpdateStreak(homeStanding.Id, 'L'); _standingsService.UpdateLastFive(homeStanding.Id, 'L'); _standingsService.UpdateStreak(awayStanding.Id, 'W'); _standingsService.UpdateLastFive(awayStanding.Id, 'W'); } else { tie = 1; _standingsService.UpdateStreak(homeStanding.Id, 'T'); _standingsService.UpdateLastFive(homeStanding.Id, 'T'); _standingsService.UpdateStreak(awayStanding.Id, 'T'); _standingsService.UpdateLastFive(awayStanding.Id, 'T'); } if (fixture.Type != "NORTH FINAL" && fixture.Type != "SOUTH FINAL" && fixture.Type != "CHAMPIONSHIP") { _standingsService.UpdateOverallStandings(homeStanding.Id, homeWin, awayWin, tie, fixture.HomeScore, fixture.AwayScore); _standingsService.UpdateOverallStandings(awayStanding.Id, awayWin, homeWin, tie, fixture.AwayScore, fixture.HomeScore); _standingsService.UpdateHomeStandings(homeStanding.Id, homeWin, awayWin, tie); _standingsService.UpdateAwayStandings(awayStanding.Id, awayWin, homeWin, tie); } if (fixture.Type == "DIVISION") { _standingsService.UpdateDivisionStandings(homeStanding.Id, homeWin, awayWin, tie); _standingsService.UpdateDivisionStandings(awayStanding.Id, awayWin, homeWin, tie); } else if (fixture.Type == "INTRA-CONFERENCE") { _standingsService.UpdateConferenceStandings(homeStanding.Id, homeWin, awayWin, tie); _standingsService.UpdateConferenceStandings(awayStanding.Id, awayWin, homeWin, tie); } }
private void UpdateChampionshipFixture() { GameDocument game = _gameService.Get(); var winners = new Dictionary <string, string>(); foreach (var conference in game.Conferences) { var fixture = _fixturesService.GetFinalsFixtures(game.Season, conference); if (fixture.HomeScore > fixture.AwayScore) { winners.Add(conference, fixture.HomeTeamId); } else { winners.Add(conference, fixture.AwayTeamId); } } var scheduleStrength = 0; string homeTeam = ""; string awayTeam = ""; foreach (var conference in game.Conferences) { winners.TryGetValue(conference, out string finalist); var leader = _standingsService.GetTeamStandings(finalist, game.Season); if (leader.ScheduleWeight >= scheduleStrength) { awayTeam = homeTeam; homeTeam = leader.TeamId; scheduleStrength = leader.ScheduleWeight; } else { awayTeam = leader.TeamId; } } _fixturesService.UpdateChampionship(game.Season, homeTeam, awayTeam); }