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);
            }
        }
예제 #2
0
 public ActionResult <List <FixturesDocument> > GetFixtures()
 {
     return(Ok(_fixturesService.Get()));
 }