Esempio n. 1
0
 public void EndRemovePartner(IAsyncResult result)
 {
     InProgress = false;
     if (result.IsCompleted)
     {
         try
         {
             bool success = PartnerService.EndRemovePartner(result);
             if (!success)
             {
                 DelegateAction(() => Partners.Add(result.AsyncState as BusinessPartnerViewModel));
             }
         }
         catch (FaultException ex)
         {
             IsError      = true;
             ErrorMessage = ex.Message;
         }
     }
 }
Esempio n. 2
0
 public void AddPartner(Partner obj)
 {
     Partners.Add(obj);
 }
        public void Populate()
        {
            Entrants.Clear();
            if (EventCode == null)
            {
                return;
            }

            var context = DataEntitiesProvider.Provide();

            var olympiadId      = CurrentOlympiadId;
            var currentOlympiad = context.Olympiad_Infoes.First(x => x.Id == CurrentOlympiadId);

            EditingThePast = !currentOlympiad.Current;
            var evt = context.Events.FirstOrDefault(x => x.OlympiadId == olympiadId && x.Code == EventCode);

            if (evt == null)
            {
                MessageBox.Show("Event " + EventCode + " didn't occur in " + currentOlympiad.YearOf);
                return;
            }

            EventId           = evt.EIN;
            Arbiter           = string.Join(", ", evt.Arbiters.Select(a => a.Name.FullName()));
            Location          = evt.Location;
            EntryFee          = evt.Entry_Fee; // nulls ok
            NumberInTeam      = evt.Number_in_Team;
            PrizeFund         = (evt.Prize_fund.HasValue) ? evt.Prize_fund.Value : 0;
            Prize1            = (evt.C1st_Prize != null) ? decimal.Parse(evt.C1st_Prize) : 0;
            Prize2            = (evt.C2nd_Prize != null) ? decimal.Parse(evt.C2nd_Prize) : 0;
            Prize3            = (evt.C3rd_Prize != null) ? decimal.Parse(evt.C3rd_Prize) : 0;
            JuniorPrize1      = (evt.JNR_1st_Prize != null) ? decimal.Parse(evt.JNR_1st_Prize) : 0;
            JuniorPrize2      = (evt.JNR_2nd_Prize != null) ? decimal.Parse(evt.JNR_2nd_Prize) : 0;
            JuniorPrize3      = (evt.JNR_3rd_Prize != null) ? decimal.Parse(evt.JNR_3rd_Prize) : 0;
            OtherPrizes       = evt.Other_Prizes;
            JuniorOtherPrizes = evt.JNR_Other_Prizes;
            Pentamind         = evt.Pentamind;
            PentamindFactor   = evt.PentamindFactor;
            IncludedInMaxFee  = (evt.incMaxFee.HasValue) ? evt.incMaxFee.Value : false;
            JuniorMedals      = (evt.JNR_Medals.HasValue) ? evt.JNR_Medals.Value : false;
            Type           = evt.Type; // NULLs OK
            ExpectedNumber = (evt.X_Num.HasValue) ? evt.X_Num.Value : 10;
            Notes          = evt.Notes;
            NumSessions    = (evt.No_Sessions.HasValue) ? (int)evt.No_Sessions : 0;
            // evt.Display; // appears not to be used
            var h = evt.Event_Sess; // collection
            // evt.MAX_Number // not used since 2006
            var t = evt.Number;     // within that year, 0 = combined event or not a game

            // evt.Prize_Giving; - has never been used, always NULL

            Sessions.Clear();
            foreach (var s in evt.Event_Sess)
            {
                Sessions.Add(new SessionVm()
                {
                    Id    = s.INDEX, Date = s.Date.Value, SessionCode = s.Session,
                    Start = s.Session1.StartTime.Value.ToString(@"hh\:mm"),
                    End   = s.Session1.FinishTime.Value.ToString(@"hh\:mm"),
                    // Todo purge the nulls out of the database (needs a whole rethink anyway)
                    Worth = (s.Session1.Worth.HasValue) ? (int)s.Session1.Worth.Value : 0
                });
            }

            var entrants = context.Entrants
                           .Join(context.Contestants, e => e.Mind_Sport_ID, c => c.Mind_Sport_ID, (e, c) => new { e = e, c = c })
                           .Where(x => x.e.OlympiadId == olympiadId && x.e.Game_Code == EventCode)
                           .OrderBy(x => x.e.Rank)
                           .ThenBy(x => x.c.Lastname).ToList();

            Partners.Clear();
            foreach (var ec in entrants.OrderBy(ec => ec.c.FullName()))
            {
                Partners.Add(ec.c.FullName());
            }


            var juniorDate = currentOlympiad.AgeDate.Value.AddYears(-currentOlympiad.JnrAge.Value - 1);

            foreach (var e in entrants)
            {
                Entrants.Add(new EntrantVm(this)
                {
                    EntrantId    = e.e.EntryNumber,
                    ContestantId = e.c.Mind_Sport_ID,
                    Medal        = e.e.Medal ?? "",
                    JuniorMedal  = e.e.JuniorMedal ?? "",
                    FirstName    = e.c.Firstname,
                    LastName     = e.c.Lastname,
                    IsJunior     = e.c.DateofBirth.HasValue && e.c.DateofBirth > juniorDate,
                    Rank         = e.e.Rank.HasValue ? e.e.Rank.Value : 0,
                    Score        = e.e.Score,
                    Absent       = e.e.Absent,
                    TieBreak     = e.e.Tie_break,
                    PentaScore   = e.e.Penta_Score.HasValue ? e.e.Penta_Score.Value : 0,
                    TeamOrPair   = e.e.Partner,
                    PIN          = e.e.PIN.HasValue ? e.e.PIN.Value.ToString() : ""
                });
            }

            OnPropertyChanged("Totals");
        }