public void UpdateRanking(IList <RacerPerson> racerPersonList, Race race, Division division)
        {
            if (!DivisionRacerSeasonRankingList.ContainsKey(division.DivisionId))
            {
                Convert(racerPersonList, division.DivisionId);
            }

            for (int i = 0; i < racerPersonList.Count; i++)
            {
                if (race.RacePointList.Any(p => p.Position == i + 1 && p.Point != 0))
                {
                    var points = race.RacePointList.Where(p => p.Position == i + 1).FirstOrDefault().Point;

                    DivisionRacerSeasonRankingList[division.DivisionId].Where(r => r.RacerPersonId == racerPersonList[i].RacerPersonId).FirstOrDefault().Points =
                        DivisionRacerSeasonRankingList[division.DivisionId].Where(r => r.RacerPersonId == racerPersonList[i].RacerPersonId).FirstOrDefault().Points +
                        points;
                }

                DivisionRacerSeasonRankingList[division.DivisionId].Where(r => r.RacerPersonId == racerPersonList[i].RacerPersonId).FirstOrDefault().Positions =
                    DivisionRacerSeasonRankingList[division.DivisionId].Where(r => r.RacerPersonId == racerPersonList[i].RacerPersonId).FirstOrDefault().Positions + (i + 1);
            }

            foreach (var team in DivisionTeamSeasonRankingList[division.DivisionId])
            {
                team.Points    = DivisionRacerSeasonRankingList[division.DivisionId].Where(r => r.Team.TeamId == team.TeamId).Sum(r => r.Points);
                team.Positions = DivisionRacerSeasonRankingList[division.DivisionId].Where(r => r.Team.TeamId == team.TeamId).Sum(r => r.Positions);
            }

            DivisionRacerSeasonRankingList[division.DivisionId] = DivisionRacerSeasonRankingList[division.DivisionId].Where(r => r.DivisionId == division.DivisionId).OrderByDescending(r => r.Points).ThenBy(r => r.Positions).ToList();
            DivisionTeamSeasonRankingList[division.DivisionId]  = DivisionTeamSeasonRankingList[division.DivisionId].Where(r => r.DivisionId == division.DivisionId).OrderByDescending(t => t.Points).ThenBy(t => t.Positions).ToList();
        }
        private void Convert(IList <RacerPerson> racerPersonList, int divisionId)
        {
            var RacerSeasonRankingList = new List <RacerSeasonRanking>();
            var TeamSeasonRankingList  = new List <TeamSeasonRanking>();

            foreach (var racerPerson in racerPersonList)
            {
                var newRacerSeasonRanking = new RacerSeasonRanking
                {
                    FlatAbility              = racerPerson.FlatAbility,
                    ClimbingAbility          = racerPerson.ClimbingAbility,
                    DownhillAbility          = racerPerson.DownhillAbility,
                    FirstName                = racerPerson.FirstName,
                    LastName                 = racerPerson.LastName,
                    Nation                   = racerPerson.Nation,
                    RacerPersonId            = racerPerson.RacerPersonId,
                    Team                     = racerPerson.Team,
                    FlatPotentialAbility     = racerPerson.FlatPotentialAbility,
                    ClimbingPotentialAbility = racerPerson.ClimbingPotentialAbility,
                    DownhillPotentialAbility = racerPerson.DownhillPotentialAbility,
                    Age        = racerPerson.Age,
                    DivisionId = divisionId
                };

                RacerSeasonRankingList.Add(newRacerSeasonRanking);

                if (!TeamSeasonRankingList.Any(t => t.TeamId == newRacerSeasonRanking.Team.TeamId))
                {
                    var newTeamSeasonRanking = new TeamSeasonRanking
                    {
                        Name       = newRacerSeasonRanking.Team.Name,
                        TeamId     = newRacerSeasonRanking.Team.TeamId,
                        DivisionId = divisionId
                    };

                    TeamSeasonRankingList.Add(newTeamSeasonRanking);
                }
            }

            DivisionRacerSeasonRankingList.Add(divisionId, RacerSeasonRankingList);
            DivisionTeamSeasonRankingList.Add(divisionId, TeamSeasonRankingList);
        }