Exemple #1
0
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>LoadAthleteInformation</name>
        /// <date>14/03/15</date>
        /// <summary>
        /// Loads the athlete information via the business library and adds it to the athlete collection.
        /// </summary>
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        private void LoadAthleteInformation()
        {
            List <AthleteDetails> orderedList = this.model.Athletes.AthleteDetails.OrderBy(athlete => athlete.Forename).ToList();

            orderedList = orderedList.OrderBy(athlete => athlete.Surname).ToList();

            this.athleteCollection = new ObservableCollection <AthleteType>();
            foreach (AthleteDetails athlete in orderedList)
            {
                this.athleteCollection.Add(
                    new AthleteType(
                        athlete.Key,
                        athlete.Name,
                        athlete.Club,
                        athlete.Sex,
                        ListOCConverter.ToObservableCollection(athlete.RunningNumbers),
                        athlete.BirthDate.BirthYear,
                        athlete.BirthDate.BirthMonth,
                        athlete.BirthDate.BirthDay,
                        athlete.SignedConsent,
                        athlete.Active,
                        athlete.PredeclaredHandicap.ToString()));
            }

            this.AthletesRaisePropertyChanged();
        }
Exemple #2
0
        //athleteCurrentSeason.Points.BestPoints));

        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        /// <name>LoadAthleteInformation</name>
        /// <date>14/03/15</date>
        /// <summary>
        /// Loads the athlete information via the business library and adds it to the athlete collection.
        /// </summary>
        /// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        private void LoadAthleteInformation(List <AthleteDetails> athletes)
        {
            NormalisationConfigType hcConfiguration =
                this.normalisationConfigManager.ReadNormalisationConfiguration();

            List <AthleteDetails> orderedList = athletes.OrderBy(athlete => athlete.Forename).ToList();

            orderedList = orderedList.OrderBy(athlete => athlete.Surname).ToList();

            this.AthleteCollection = new ObservableCollection <AthleteCompleteViewModel>();
            foreach (AthleteDetails athlete in orderedList)
            {
                AthleteSeasonDetails athleteCurrentSeason =
                    this.model.CurrentSeason.Athletes.Find(a => a.Key == athlete.Key);

                if (athleteCurrentSeason == null)
                {
                    athleteCurrentSeason =
                        new AthleteSeasonDetails(
                            athlete.Key,
                            athlete.Name,
                            this.resultsConfigurationManager);
                }

                string handicap = athleteCurrentSeason.GetRoundedHandicap(hcConfiguration)?.ToString() ?? athlete.RoundedHandicap.ToString();

                this.AthleteCollection.Add(
                    new AthleteCompleteViewModel(
                        athlete.Key,
                        athlete.Name,
                        athlete.Club,
                        athlete.Sex.ToString(),
                        handicap,
                        athlete.PB.ToString(),
                        athlete.LastAppearance.ToString(),
                        athlete.Appearances,
                        athlete.SignedConsent,
                        athlete.Active,
                        athleteCurrentSeason.SB.ToString(),
                        ListOCConverter.ToObservableCollection(athlete.RunningNumbers),
                        this.ConvertAppearances(athleteCurrentSeason.Times),
                        this.ConvertAppearances(athlete.Times),
                        athleteCurrentSeason.Points.TotalPoints,
                        athleteCurrentSeason.Points.FinishingPoints,
                        athleteCurrentSeason.Points.PositionPoints,
                        athleteCurrentSeason.Points.BestPoints));
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the current athlete list and add registered athletes in numerical order.
        /// </summary>
        private void GetCurrentAthleteList()
        {
            //List<AthleteSeasonDetails> orderedList = Model.Instance.CurrentSeason.Athletes.OrderBy(athlete => athlete.PrimaryNumber).ToList();

            RegisteredAthletes = new ObservableCollection <AthleteSeasonBase>();

            foreach (AthleteSeasonDetails athlete in this.model.CurrentSeason.Athletes)
            {
                RegisteredAthletes.Add(
                    new AthleteSeasonBase(
                        athlete.Key,
                        athlete.Name,
                        ListOCConverter.ToObservableCollection(
                            this.model.Athletes.GetAthleteRunningNumbers(
                                athlete.Key))));
            }
        }
Exemple #4
0
        /// <date>14/03/15</date>
        /// <summary>
        /// Saves the current list to a file.
        /// </summary>
        public void SaveAthletes()
        {
            foreach (AthleteType athlete in AthleteCollection)
            {
                switch (athlete.Status)
                {
                case StatusType.Added:
                    if (athlete.PredeclaredHandicap.Contains(":"))
                    {
                        int initialHandicapMinutes = 0;
                        int initialHandicapSeconds = 0;

                        if (int.TryParse(athlete.PredeclaredHandicap.Substring(0, athlete.PredeclaredHandicap.IndexOf(":")), out initialHandicapMinutes))
                        {
                            if (int.TryParse(athlete.PredeclaredHandicap.Substring(athlete.PredeclaredHandicap.IndexOf(":") + 1), out initialHandicapSeconds))
                            {
                                this.model.CreateNewAthlete(
                                    athlete.Name,
                                    athlete.Club,
                                    initialHandicapMinutes,
                                    initialHandicapSeconds,
                                    athlete.Sex,
                                    ListOCConverter.ToList(athlete.RunningNumbers),
                                    athlete.BirthYear,
                                    athlete.BirthMonth,
                                    athlete.BirthDay,
                                    athlete.SignedConsent,
                                    athlete.Active);
                            }
                        }
                    }
                    else
                    {
                        int initialHandicap = 0;
                        if (int.TryParse(athlete.PredeclaredHandicap, out initialHandicap))
                        {
                            this.model.CreateNewAthlete(
                                athlete.Name,
                                athlete.Club,
                                initialHandicap,
                                athlete.Sex,
                                ListOCConverter.ToList(athlete.RunningNumbers),
                                athlete.BirthYear,
                                athlete.BirthMonth,
                                athlete.BirthDay,
                                athlete.SignedConsent,
                                athlete.Active);
                        }
                    }

                    break;

                case StatusType.Deleted:
                    this.model.DeleteAthlete(athlete.Key);
                    break;

                case StatusType.Updated:
                    this.model.UpdateAthlete(
                        athlete.Key,
                        athlete.Club,
                        ListOCConverter.ToList(athlete.RunningNumbers),
                        athlete.SignedConsent,
                        athlete.Active,
                        new TimeType(athlete.PredeclaredHandicap));
                    break;

                default:
                    break;
                }
            }

            this.model.SaveAthleteList();
            ResetSelectedIndex();
            LoadAthleteInformation();

            Messenger.Default.Send(
                new HandicapProgressMessage(
                    "Athletes Saved"));
        }