29 _personService = personService;
31 _competitionService = competitionService;
32 _workspaceService = workspaceService;
34 _workspaceService.PropertyChanged += (sender, e) =>
49 _competitionService.UpdateAllCompetitionsForPerson(person);
51 foreach (
PersonStart start
in person?.Starts?.Values)
53 if (start ==
null) {
continue; }
63 if (competition ==
null) {
continue; }
66 if (start.
Time.TotalMilliseconds == 0)
79 ushort scoreFractionalDigits = _workspaceService?.Settings?.GetSettingValue<ushort>(
WorkspaceSettings.GROUP_GENERAL,
WorkspaceSettings.SETTING_GENERAL_SCORE_FRACTIONAL_DIGITS) ?? 1;
80 start.Score = Math.Round(start.Score, scoreFractionalDigits);
83 if (start.Score < 0) { start.Score = 0; }
94 foreach(
Person person
in _personService.GetPersons())
106 List<PersonStart> bestStarts =
new List<PersonStart>();
107 bestStarts = sortedPersons.Where(p => p.HighestScoreStyle !=
SwimmingStyles.Unknown && p.Starts[p.HighestScoreStyle] !=
null)?.Select(p => p.Starts[p.HighestScoreStyle]).ToList();
110 List<IGrouping<double, PersonStart>> groupedStarts = bestStarts.GroupBy(s => s.Score).ToList();
111 sortedPersons.ForEach(p => p.ResultListPlace = 0);
114 personStart.PersonObj.ResultListPlace = groupedStarts.IndexOf(groupedStarts.FirstOrDefault(g => g.Contains(personStart))) + 1;
127 List<Person> persons =
new List<Person>(_personService.GetPersons());
128 persons = onlyActivePersons ? persons.Where(p => p.IsActive).ToList() : persons;
132 return persons.OrderByDescending(p => p.HighestScore).ToList();
134 else if(resultType ==
ResultTypes.MaxAgeCompetitions)
136 return persons.Where(p => p.Starts[p.HighestScoreStyle].IsUsingMaxAgeCompetition).OrderByDescending(p => p.HighestScore).ToList();
141 return persons.Where(p => p.Starts[style] !=
null).OrderByDescending(p => p.Starts[style].Score).ToList();
156 List<PersonStart> bestStarts =
new List<PersonStart>();
159 bestStarts = sortedPersons.Where(p => p.HighestScoreStyle !=
SwimmingStyles.Unknown && p.Starts[p.HighestScoreStyle] !=
null)?.Select(p => p.Starts[p.HighestScoreStyle]).ToList();
164 bestStarts = sortedPersons.Where(p => p.Starts[style] !=
null)?.Select(p => p.Starts[style]).ToList();
166 bestStarts = bestStarts.Where(s => s.IsActive).ToList();
169 List<IGrouping<double, PersonStart>> groupedStarts = bestStarts.GroupBy(s => s.Score).ToList();
172 return groupedStarts[0].ToList();
176 return groupedStarts[1].ToList();
180 return groupedStarts[2].ToList();
Class describing a competition.
TimeSpan BestTime
Time for this competition to reach the maximum points.
Class describing a person.
Class describing a start of a person.
TimeSpan Time
Time the person needed during the race of this start.
Competition CompetitionObj
Reference to the competition object to which the start belongs.
const int BEST_TIME_SCORE
Score that a person gets if the start time equals the competition best time.
List< Person > GetPersonsSortedByScore(ResultTypes resultType, bool onlyActivePersons)
Get all persons, sort them depending on the requested ResultTypes and return as new list.
ScoreService(IPersonService personService, ICompetitionService competitionService, IWorkspaceService workspaceService)
Constructor for the ScoreService
void UpdateScoresForAllPersons()
Update all scores for all Person
void UpdateScoresForPerson(Person person)
Update all scores for this Person
void UpdateResultListPlacesForAllPersons()
Update the result list places for all Person.
List< PersonStart > GetWinnersPodiumStarts(ResultTypes resultType, ResultPodiumsPlaces podiumsPlace)
Find the best starts of all persons depending on the ResultTypes and requested ResultPodiumsPlaces Th...
Class holding all workspace settings.
Interface for a service used to get and store a list of objects.
Interface for a service used to get and store a list of Person objects.
void SetScoreServiceObj(IScoreService scoreService)
Save the reference to the IScoreService object.
Interface for a service used to calculate the scores for all persons.
Interface for a service used to manage a workspace.
WorkspaceSettings Settings
Settings for the current workspace.
SwimmingStyles
Available swimming styles.
ResultTypes
Available result types.
ResultPodiumsPlaces
Available result podium types.