Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
ResultsViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using System.Windows.Data;
8
10
14public partial class ResultsViewModel : ObservableObject, INavigationAware
15{
19 [ObservableProperty]
20 private List<Person> _sortedPersons;
21
22 private ResultTypes _resultType = ResultTypes.Overall;
27 {
28 get => _resultType;
29 set
30 {
31 if (SetProperty(ref _resultType, value))
32 {
33 updatePersonsAndPlaces();
34 }
35 }
36 }
37
41 public List<PersonStart> PodiumGoldStarts => _scoreService.GetWinnersPodiumStarts(ResultType, ResultPodiumsPlaces.Gold);
42
46 public List<PersonStart> PodiumSilverStarts => _scoreService.GetWinnersPodiumStarts(ResultType, ResultPodiumsPlaces.Silver);
47
51 public List<PersonStart> PodiumBronzeStarts => _scoreService.GetWinnersPodiumStarts(ResultType, ResultPodiumsPlaces.Bronze);
52
53 private IScoreService _scoreService;
54
59 public ResultsViewModel(IScoreService scoreService)
60 {
61 _scoreService = scoreService;
62 ResultType = ResultTypes.Overall;
63 updatePersonsAndPlaces();
64 }
65
67 public void OnNavigatedTo(object parameter)
68 {
69 updatePersonsAndPlaces();
70 }
71
73 public void OnNavigatedFrom()
74 {
75 }
76
77 private void updatePersonsAndPlaces()
78 {
79 SortedPersons = _scoreService.GetPersonsSortedByScore(ResultType, true);
81 OnPropertyChanged(nameof(PodiumGoldStarts));
82 OnPropertyChanged(nameof(PodiumSilverStarts));
83 OnPropertyChanged(nameof(PodiumBronzeStarts));
84 }
85}
ResultsViewModel(IScoreService scoreService)
Constructor of the results view model.
List< PersonStart > PodiumSilverStarts
List with all starts on the silver podium place (second highest scores)
List< PersonStart > PodiumBronzeStarts
List with all starts on the bronze podium place (third highest scores)
List< PersonStart > PodiumGoldStarts
List with all starts on the gold podium place (highest scores)
ResultTypes ResultType
Type of result to view.
void OnNavigatedFrom()
OnNavigatedFrom method to handle navigation away from this object.
List< Person > _sortedPersons
List with all persons sorted by score.
void OnNavigatedTo(object parameter)
OnNavigatedTo method to handle navigation to this object.
Interface for objects that need to handle navigation events.
Interface for a service used to calculate the scores for all persons.
List< Person > GetPersonsSortedByScore(ResultTypes resultType=ResultTypes.Overall, bool onlyActivePersons=true)
Get all persons, sort them depending on the requested ResultTypes and return as new list.
void UpdateResultListPlacesForAllPersons()
Update the result list places for all Person.
ResultTypes
Available result types.
Definition ResultTypes.cs:7
ResultPodiumsPlaces
Available result podium types.