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
AnalyticsModuleStartsPerPerson.cs
5
7{
12 {
13 private IPersonService _personService;
14
20 {
21 _personService = personService;
22 }
23
25 public bool AnalyticsAvailable => _personService.PersonCount > 0;
26
30 public Dictionary<Person, int> NumberStartsPerPerson => _personService.GetPersons()
31 .Where(p => p.IsActive)
32 .ToDictionary(p => p, p => p.Starts.Count(s => s.Value != null && s.Value.IsCompetitionObjAssigned))
33 .OrderByDescending(p => p.Value)
34 .ToDictionary();
35
38 {
39 DocXPlaceholderHelper.TextPlaceholders textPlaceholder = new DocXPlaceholderHelper.TextPlaceholders();
40 Dictionary<Person, int> numberStartsPerPerson = NumberStartsPerPerson;
41
42 // Get the joined name strings for each person and determine the maximum length of these strings (will be used for padding)
43 Dictionary<Person, string> nameStringsDict = numberStartsPerPerson.ToDictionary(kv => kv.Key, kv => $"{kv.Key.FirstName}, {kv.Key.Name}");
44 int maxNameStrLen = nameStringsDict.Max(kv => kv.Value?.Length) ?? 30;
45
46 // Create a string for each dictionary entry including a ASCII diagramm (Format e.g.: Firstname, Name: 3x | ###)
47 string moduleString = string.Join(Environment.NewLine,
48 numberStartsPerPerson
49 .Select(kv => $"{nameStringsDict[kv.Key]}: ".PadRight(maxNameStrLen + 2) +
50 $"{kv.Value.ToString()}x | {new string('#', kv.Value)}"));
51 foreach (string placeholder in Placeholders.Placeholders_AnalyticsStartsPerPerson) { textPlaceholder.Add(placeholder, moduleString); }
52 return textPlaceholder;
53 }
54
56 public List<string> SupportedDocumentPlaceholderKeys => new List<string>()
57 {
58 Placeholders.PLACEHOLDER_KEY_ANALYTICS_STARTS_PER_PERSON
59 };
60 }
61}
Dictionary< Person, int > NumberStartsPerPerson
Number of starts (value) per person (key).
List< string > SupportedDocumentPlaceholderKeys
List of all document placeholder keys that are supported by this analytics module....
AnalyticsModuleStartsPerPerson(IPersonService personService)
Constructor for the AnalyticsModuleStartsPerPerson
bool AnalyticsAvailable
Flag indicating if the analytics module has data.
DocXPlaceholderHelper.TextPlaceholders CollectDocumentPlaceholderContents()
Collect the values for all document placeholders that are supported by this IAnalyticsModule....
Interface for a service used to get and store a list of Person objects.