예제 #1
0
        /// <summary>
        /// Apply the raw results to the model and save to disk.
        /// </summary>
        private bool SaveRawEventResults()
        {
            List <IRaw> rawList = new List <IRaw>();

            foreach (RawResults result in AllAthletes.FindAll(athlete => athlete.RaceNumber != string.Empty))
            {
                rawList.Add(new Raw(result.RaceNumber, result.RaceTime, result.Order));
            }

            return(this.handicapEventModel.SaveRawResults(rawList));
        }
예제 #2
0
        async public Task GetAllAthletes(bool forceRefresh = false)
        {
            if (_hasLoadedBefore && !forceRefresh)
            {
                return;
            }

            AllAthletes.Clear();

            var task = AzureService.Instance.GetAllAthletes();

            await RunSafe(task);

            if (task.IsFaulted)
            {
                return;
            }

            _hasLoadedBefore = true;
            LocalRefresh();
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        private void RegisterNewResult(string raceNumber, RaceTimeType raceTime)
        {
            RawResults result = this.FindAthlete(raceNumber);

            if (result != null)
            {
                result.RaceNumber = raceNumber;
                result.RaceTime   = raceTime;

                // Determine the finish order if two or more athletes share the same finishing time.
                List <RawResults> filteredList = AllAthletes.FindAll(athlete => athlete.RaceTime == result.RaceTime);
                result.Order = filteredList.Count();

                ResetMemberData();

                RaisePropertyChangedEvent("UnregisteredAthletes");
                RaisePropertyChangedEvent("RegisteredAthletes");
            }
            else
            {
                // The athlete is unknown. Add the data to all athletes, all athletes is read
                // when saving the raw results.
                ObservableCollection <string> newNumber = new ObservableCollection <string> {
                    raceNumber
                };
                RawResults newResult = new RawResults(0, string.Empty, newNumber);
                newResult.RaceTime   = raceTime;
                newResult.RaceNumber = raceNumber;

                // Determine the finish order if two or more athletes share the same finishing time.
                List <RawResults> filteredList = AllAthletes.FindAll(athlete => athlete.RaceTime == raceTime);
                newResult.Order = filteredList.Count();

                this.AllAthletes.Add(newResult);
            }
        }
예제 #4
0
 public void LocalRefresh()
 {
     AllAthletes.Clear();
     DataManager.Instance.Athletes.Values.OrderBy(a => a.Name).ToList().ForEach(AllAthletes.Add);
 }