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
DocumentStrategyCertificates.cs
7
9{
14 {
15 private readonly IPersonService _personService;
16
23 public DocumentStrategyCertificates(IPersonService personService, IWorkspaceService workspaceService, IServiceProvider serviceProvider) : base(workspaceService, serviceProvider)
24 {
25 _personService = personService;
26 }
27
30
32 public override string TemplatePath => DocumentService.GetDocumentPathAbsolute(WorkspaceSettings.SETTING_DOCUMENT_CREATION_CERTIFICATE_TEMPLATE_PATH, _workspaceService);
33
35 public override string TemplateFileNamePostfixReplaceStr
36 {
37 get
38 {
39 if (ItemFilter is PersonStartFilters)
40 {
41 string templateFileNamePostfixReplaceStr = string.Empty;
42 switch ((PersonStartFilters)ItemFilter)
43 {
44 case PersonStartFilters.None:
45 break;
46 case PersonStartFilters.Person:
47 if (ItemFilterParameter is Person) { templateFileNamePostfixReplaceStr = "_" + ((Person)ItemFilterParameter).FirstName + "_" + ((Person)ItemFilterParameter).Name; }
48 break;
49 case PersonStartFilters.SwimmingStyle:
50 if (ItemFilterParameter is SwimmingStyles) { templateFileNamePostfixReplaceStr = "_" + EnumCoreLocalizedStringHelper.Convert((SwimmingStyles)ItemFilterParameter); }
51 break;
52 case PersonStartFilters.CompetitionID:
53 if (ItemFilterParameter is int || ItemFilterParameter is double) { templateFileNamePostfixReplaceStr = "_WK" + Convert.ToInt32(ItemFilterParameter); }
54 break;
55 default: break;
56 }
57 return templateFileNamePostfixReplaceStr;
58 }
59 else
60 {
61 return base.TemplateFileNamePostfixReplaceStr;
62 }
63 }
64 }
65
69 public override bool CreateMultiplePages => true;
70
72 public override Enum ItemOrdering { get; set; } = ItemOrderingsCertificate.None;
73
75 public override IEnumerable<Enum> AvailableItemOrderings => Enum.GetValues(typeof(ItemOrderingsCertificate)).Cast<Enum>();
76
78 public override IEnumerable<Enum> AvailableItemFilters => Enum.GetValues(typeof(PersonStartFilters)).Cast<Enum>();
79
81 public override Enum ItemFilter { get; set; } = PersonStartFilters.None;
82
84 public override object ItemFilterParameter { get; set; } = null;
85
90 public override PersonStart[] GetItems()
91 {
92 PersonStartFilters personStartFilter = PersonStartFilters.None;
93 object personStartFilterParameter = null;
94
96 {
97 personStartFilter = (PersonStartFilters)ItemFilter;
98 switch(personStartFilter)
99 {
100 case PersonStartFilters.Person:
101 if(ItemFilterParameter is Person) { personStartFilterParameter = ItemFilterParameter as Person; }
102 break;
103 case PersonStartFilters.SwimmingStyle:
104 if (ItemFilterParameter is SwimmingStyles) { personStartFilterParameter = (SwimmingStyles)ItemFilterParameter; }
105 break;
106 case PersonStartFilters.CompetitionID:
107 if (ItemFilterParameter is int || ItemFilterParameter is double) { personStartFilterParameter = Convert.ToInt32(ItemFilterParameter); }
108 break;
109 }
110 if(personStartFilterParameter == null) { personStartFilter = PersonStartFilters.None; }
111 }
112
113 List<PersonStart> starts = _personService.GetAllPersonStarts(personStartFilter, personStartFilterParameter).Where(s => s.CompetitionObj != null && s.IsActive).ToList();
114 switch (ItemOrdering)
115 {
116 case ItemOrderingsCertificate.ByNameAscending: starts = starts.OrderBy(s => s.PersonObj?.Name).ToList(); break;
117 case ItemOrderingsCertificate.ByNameDescending: starts = starts.OrderByDescending(s => s.PersonObj?.Name).ToList(); break;
118 case ItemOrderingsCertificate.ByFirstNameAscending: starts = starts.OrderBy(s => s.PersonObj?.FirstName).ToList(); break;
119 case ItemOrderingsCertificate.ByFirstNameDescending: starts = starts.OrderByDescending(s => s.PersonObj?.FirstName).ToList(); break;
120 case ItemOrderingsCertificate.ByCompetitionAscending: starts = starts.OrderBy(s => s.CompetitionObj?.Id).ToList(); break;
121 case ItemOrderingsCertificate.ByCompetitionDescending: starts = starts.OrderByDescending(s => s.CompetitionObj?.Id).ToList(); break;
122 default: break;
123 }
124 return starts.ToArray();
125 }
126
127 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
128
133 {
134 None,
135 ByNameAscending,
136 ByNameDescending,
137 ByFirstNameAscending,
138 ByFirstNameDescending,
139 ByCompetitionAscending,
140 ByCompetitionDescending
141 }
142 }
143
144}
DocumentStrategyBase(IWorkspaceService workspaceService, IServiceProvider serviceProvider)
Constructor for the document strategy base class.
override PersonStart[] GetItems()
Return a list of all PersonStart items which have PersonStart.CompetitionObj assigned.
DocumentStrategyCertificates(IPersonService personService, IWorkspaceService workspaceService, IServiceProvider serviceProvider)
Constructor for the document strategy for certificates.
override IEnumerable< Enum > AvailableItemOrderings
Array with all available orderings for the items.If no ordering is supported, this will be null.
override DocumentCreationTypes DocumentType
Gets the type of document this strategy creates.
override object ItemFilterParameter
Filter parameter that can be used together with ItemFiltering.The type and usage of this parameter de...
override Enum ItemOrdering
Current ordering for the items.If no ordering is supported, this will be null.
override string TemplatePath
Gets the path to the template used for creating the document.
override string TemplateFileNamePostfixReplaceStr
Use this string instead of the template file name postfix during document creation....
override Enum ItemFilter
Current filter for the items.If no filtering is supported, this will be null.
override IEnumerable< Enum > AvailableItemFilters
Array with all available filters for the items.If no filtering is supported, this will be null.
Class describing a person.
Definition Person.cs:12
Class describing a start of a person.
Definition PersonStart.cs:9
Service used to create documents like certificates or start lists.
static string GetDocumentPathAbsolute(string documentCreationSettingKey, IWorkspaceService workspaceService)
Get the absolute path for the requested document creation setting.
Interface for a service used to get and store a list of Person objects.
Interface for a service used to manage a workspace.
SwimmingStyles
Available swimming styles.
DocumentCreationTypes
Different types of documents that can be created.
PersonStartFilters
Available filters for PersonStart objects.