public async Task CreateNewTeamRankingAsync(Team team, Season season)
        {
            if (team == null)
            {
                throw new ArgumentNullException(nameof(team));
            }
            if (season == null)
            {
                throw new ArgumentNullException(nameof(season));
            }

            // Find the worst rank in the basic bracket
            var neverLucky = await _db.RankBrackets
                    .Include(x => x.Season)
                    .SingleOrDefaultAsync(x => x.Type == RankBrackets.NeverLucky && x.Season.SeasonId == season.SeasonId);

            if (neverLucky == null)
            {
                throw new InvalidProgramException("Unable to load baseline bracket for new team");
            }

            var rank = new Rank
            {
                RankBracket = neverLucky,
                Rating = new Rating { MatchMakingRating = 1500 }
            };

            team.Rank = rank;

            _db.Add(rank);
            _db.Add(rank.Rating);
            _db.Update(team);

            await _db.SaveChangesAsync();
        }
        public async Task CreateDefaultSeason(string seasonName)
        {
            if (string.IsNullOrEmpty(seasonName))
            {
                throw new ArgumentNullException(nameof(seasonName));
            }

            if (!await _db.DefaultSeasons.AnyAsync(x => x.Name == Defaults.DefaultSeason))
            {
                var season = new Season
                {
                    Name = seasonName,
                    Brackets = new RankBracket[]
                    {
                        new RankBracket { Type = RankBrackets.NeverLucky, Name = "Never Lucky", MinimumMMR = 0, MaximumMMR = 1599 },
                        new RankBracket { Type = RankBrackets.Common, Name = "Common", MinimumMMR = 1600, MaximumMMR = 2199 },
                        new RankBracket { Type = RankBrackets.Rare, Name = "Rare", MinimumMMR = 2199, MaximumMMR = 2599 },
                        new RankBracket { Type = RankBrackets.Legendary, Name = "Legendary", MinimumMMR = 2600, MaximumMMR = 9999 }
                    }
                };

                foreach (var bracket in season.Brackets)
                {
                    bracket.Season = season;
                    _db.Add(bracket);
                }

                _db.Add(season);
                _db.Add(new DefaultSeason { Name = Defaults.DefaultSeason, Season = season });

                await _db.SaveChangesAsync();
            }
        }