public void PopulateDropdown()
        {
            Olympiads.Clear();
            var context = DataEntitiesProvider.Provide();

            foreach (var o in context.Olympiad_Infoes.OrderByDescending(x => x.StartDate))
            {
                Olympiads.Add(new OlympiadVm {
                    Text = o.FullTitle(), Id = o.Id
                });
            }

            OlympiadId = Olympiads.First().Id;
        }
        public void PopulateOlympiadDropdown()
        {
            Olympiads.Clear();
            var context = DataEntitiesProvider.Provide();

            foreach (var c in context.Olympiad_Infoes
                     .OrderByDescending(x => x.StartDate))
            {
                Olympiads.Add(new OlympiadVm {
                    Text = c.FullTitle(), Value = c.Id
                });
            }
            CurrentOlympiadId = Olympiads.First().Value;
        }
        public void PopulateEvents()
        {
            Events.Clear();
            if (ContestantId == null)
            {
                return;
            }

            EditingThePast = (CurrentOlympiadId != Olympiads.First().Value);

            var context    = DataEntitiesProvider.Provide();
            var olympiadId = CurrentOlympiadId;
            var olympiad   = context.Olympiad_Infoes.First(x => x.Id == CurrentOlympiadId);

            IsJuniorForOlympiad = Contestant.IsJuniorForOlympiad(DateOfBirth, olympiad);
            var contestantId = int.Parse(ContestantId);
            var entrants     = context.Entrants
                               .Where(x => x.Event.OlympiadId == olympiadId && x.Mind_Sport_ID == contestantId)
                               .OrderBy(x => x.Event.Code).ToList();

            var allFees = context.Fees.ToList();
            var fees    = (IsJuniorForOlympiad)
                ? allFees.ToDictionary(x => x.Code, x => x.Concession)
                : allFees.ToDictionary(x => x.Code, x => x.Adult);

            foreach (var e in entrants)
            {
                // TODO: this is really an EntrantVm not an EventVm
                Events.Add(new EventVm()
                {
                    EventId          = e.EventId.Value,
                    Absent           = e.Absent,
                    EventCode        = e.Event.Code,
                    EventName        = e.Event.Mind_Sport,
                    Fee              = e.Fee,
                    StandardFee      = (e.Event.Entry_Fee != null) ? fees[e.Event.Entry_Fee].Value : 0,
                    IncludedInMaxFee = (e.Event.incMaxFee.HasValue && e.Event.incMaxFee.Value),
                    IsEvent          = (e.Event.Number > 0),
                    Medal            = e.Medal ?? "",
                    JuniorMedal      = e.JuniorMedal ?? "",
                    Partner          = e.Partner ?? "",
                    Penta            = e.Penta_Score.HasValue ? e.Penta_Score.Value.ToString() : "",
                    Rank             = e.Rank.HasValue ? e.Rank.Value : 0,
                    Receipt          = e.Receipt.Value,
                    TieBreak         = e.Tie_break ?? "",
                    Date             = e.Event.Start
                });
            }
        }