private Dictionary <string, string> GetDivisionalRankings() { GameDocument game = _gameService.Get(); Dictionary <string, string> teamRankings = new Dictionary <string, string>(); foreach (var conference in game.Conferences) { foreach (var division in game.Divisions) { int rank = 1; List <StandingsDocument> teams = _standingsService.GetDivisionStandings(conference, division, game.Season); foreach (var team in teams) { var keyString = conference + division + rank.ToString(); teamRankings.Add(keyString, team.TeamId); rank++; } } } return(teamRankings); }
private void UpdateDivisionRankings() { GameDocument game = _gameService.Get(); foreach (var conference in game.Conferences) { foreach (var division in game.Divisions) { var divisionStandings = _standingsService.GetDivisionStandings(conference, division, game.Season); var newDivisionRank = divisionStandings.OrderByDescending(o => o.OverallPct) .ThenByDescending(o => o.DivisionPct) .ThenByDescending(o => o.ConferencePct) .ThenByDescending(o => (o.OverallPointsFor - o.OverallPointsAgainst)).ToList(); var rank = 1; foreach (var record in newDivisionRank) { _standingsService.UpdateDivisionRank(record.Id, rank); rank++; } } } }
public ActionResult <List <StandingsDocument> > GetDivisionStandings(string conference, string division, int season) { return(Ok(_standingsService.GetDivisionStandings(conference, division, season))); }