예제 #1
0
        /// <summary>
        /// Calculate and populate the athletes points table.
        /// </summary>
        private void PopulatePointsTable()
        {
            Athletes athletesModel = this.model.Athletes;

            foreach (IAthleteSeasonDetails athlete in this.seasonModel.Athletes)
            {
                if (athlete.Points.TotalPoints > 0)
                {
                    double averagePoints = 0;
                    if (athlete.NumberOfAppearances > 0)
                    {
                        averagePoints = (double)athlete.Points.TotalPoints / (double)athlete.NumberOfAppearances;
                    }

                    TimeType pb            = athletesModel.GetPB(athlete.Key);
                    string   runningNumber =
                        athletesModel.GetAthleteRunningNumber(
                            athlete.Key);

                    AthleteDetails athleteModel =
                        athletesModel.GetAthlete(
                            athlete.Key);

                    if (athleteModel == null)
                    {
                        // TODO: Unexpected, it should be logged.
                        continue;
                    }

                    PointsTableRowViewModel newRow =
                        new PointsTableRowViewModel(
                            athlete,
                            athleteModel,
                            this.OrderTable);

                    this.PointsTable.Add(newRow);
                }
            }

            this.PointsTable =
                new ObservableCollection <PointsTableRowViewModel>(
                    this.PointsTable.OrderByDescending(
                        order => order.Points));
        }
예제 #2
0
        /// <summary>
        /// Calculate and populate the athletes points table.
        /// </summary>
        private void PopulatePointsTable()
        {
            Athletes athletesModel = this.model.Athletes;

            foreach (AthleteSeasonDetails athlete in this.seasonModel.Athletes)
            {
                if (athlete.Points.TotalPoints > 0)
                {
                    double averagePoints = 0;
                    if (athlete.NumberOfAppearances > 0)
                    {
                        averagePoints = (double)athlete.Points.TotalPoints / (double)athlete.NumberOfAppearances;
                    }

                    TimeType pb            = athletesModel.GetPB(athlete.Key);
                    string   runningNumber =
                        athletesModel.GetAthleteRunningNumber(
                            athlete.Key);

                    this.PointsTable.Add(
                        new PointsTableRowViewModel(
                            athlete.Key,
                            athlete.Name,
                            pb,
                            athlete.Points.TotalPoints,
                            athlete.Points.FinishingPoints,
                            athlete.Points.PositionPoints,
                            athlete.Points.BestPoints,
                            runningNumber,
                            athlete.NumberOfAppearances,
                            averagePoints.ToString("0.##"),
                            athlete.SB));
                }
            }

            this.PointsTable =
                new ObservableCollection <PointsTableRowViewModel>(
                    PointsTable.OrderByDescending(
                        order => order.Points));
        }