public FlowDocument Print()
        {
            var rg      = new PentamindStandingsGenerator();
            var results = rg.GetStandings(null);

            return(Print(results, "Pentamind Standings"));
        }
Ejemplo n.º 2
0
        public void FreezePentamind()
        {
            var context         = DataEntitiesProvider.Provide();
            var currentOlympiad = context.Olympiad_Infoes.First(x => x.Current);

            // First of all, for each pentamind qualifier make a PEWC entry
            var pentamindStandingsGenerator = new PentamindStandingsGenerator();
            var standings = pentamindStandingsGenerator.GetStandings(null);
            int rank      = 1;

            foreach (var standing in standings.Standings)
            {
                if (!standing.IsValid)
                {
                    continue;
                }

                var contestant = context.Contestants.FirstOrDefault(x => x.Mind_Sport_ID == standing.ContestantId);
                var evt        = context.Events.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id && x.Code == "PEWC");
                var entry      = context.Entrants.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id &&
                                                                 x.Game_Code == "PEWC" && x.Mind_Sport_ID == standing.ContestantId);
                if (entry == null)
                {
                    entry = Entrant.NewEntrant(evt.EIN, "PEWC", currentOlympiad.Id, contestant, 0m);
                    context.Entrants.Add(entry);
                }
                entry.Score = standing.TotalScoreStr;
                entry.Rank  = rank;
                entry.Medal = MedalForRank(rank);
                rank++;
                context.SaveChanges();
            }

            rank = 1;
            foreach (var standing in standings.Standings.Where(x => x.IsInWomensPenta))
            {
                if (!standing.IsValid)
                {
                    continue;
                }

                var contestant = context.Contestants.FirstOrDefault(x => x.Mind_Sport_ID == standing.ContestantId);
                var evt        = context.Events.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id && x.Code == "PEWO");
                var entry      = context.Entrants.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id &&
                                                                 x.Game_Code == "PEWO" && x.Mind_Sport_ID == standing.ContestantId);
                if (entry == null)
                {
                    entry = Entrant.NewEntrant(evt.EIN, "PEWO", currentOlympiad.Id, contestant, 0m);
                    context.Entrants.Add(entry);
                }
                entry.Score = standing.TotalScoreStr;
                entry.Rank  = rank;
                entry.Medal = MedalForRank(rank);
                rank++;
                context.SaveChanges();
            }

            rank = 1;
            foreach (var standing in standings.Standings.Where(x => x.IsJunior))
            {
                if (!standing.IsValid)
                {
                    continue;
                }

                var contestant = context.Contestants.FirstOrDefault(x => x.Mind_Sport_ID == standing.ContestantId);
                var evt        = context.Events.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id && x.Code == "PEJR");
                var entry      = context.Entrants.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id &&
                                                                 x.Game_Code == "PEJR" && x.Mind_Sport_ID == standing.ContestantId);
                if (entry == null)
                {
                    entry = Entrant.NewEntrant(evt.EIN, "PEJR", currentOlympiad.Id, contestant, 0m);
                    context.Entrants.Add(entry);
                }
                entry.Score = standing.TotalScoreStr;
                entry.Rank  = rank;
                entry.Medal = MedalForRank(rank);
                rank++;
                context.SaveChanges();
            }

            rank = 1;
            foreach (var standing in standings.Standings.Where(x => x.IsSenior))
            {
                if (!standing.IsValid)
                {
                    continue;
                }

                var contestant = context.Contestants.FirstOrDefault(x => x.Mind_Sport_ID == standing.ContestantId);
                var evt        = context.Events.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id && x.Code == "PESR");
                var entry      = context.Entrants.FirstOrDefault(x => x.OlympiadId == currentOlympiad.Id &&
                                                                 x.Game_Code == "PESR" && x.Mind_Sport_ID == standing.ContestantId);
                if (entry == null)
                {
                    entry = Entrant.NewEntrant(evt.EIN, "PESR", currentOlympiad.Id, contestant, 0m);
                    context.Entrants.Add(entry);
                }
                entry.Score = standing.TotalScoreStr;
                entry.Rank  = rank;
                entry.Medal = MedalForRank(rank);
                rank++;
                context.SaveChanges();
            }
        }