diff --git a/Service/Plugins/SupportConceptValidator.cs b/Service/Plugins/SupportConceptValidator.cs index a2fe72359..4b5dcc55d 100644 --- a/Service/Plugins/SupportConceptValidator.cs +++ b/Service/Plugins/SupportConceptValidator.cs @@ -27,17 +27,57 @@ namespace BeWo.Service.Plugins bool isNew = !supportConcept.SupportConceptOid.HasValue; + // 1. Prüfe Datumsbereiche. Startdatum darf nicht größer als Enddatum sein + bool containsDatumCheck = false; + if (supportConcept.CostBearerRelations != null) + { + foreach (var c2s in supportConcept.CostBearerRelations) + { + if (!containsDatumCheck) + { + var val = CheckDate(c2s.StartDate, c2s.EndDate); + if (val != null) + { + result.Add(val); + containsDatumCheck = true; + } - // 1. Prüfe Datumsbereiche. Startdatum darf nicht größer als Enddatum sein - - //ValidationResultDC resultDc = new ValidationResultDC(); - //resultDc.Message = "Alles doof! Darfst nicht speichern!"; - //resultDc.AllowSave = true; - // result.Add(resultDc); + if (c2s.ApprovalPeriodList != null) + { + foreach (var ap in c2s.ApprovalPeriodList) + { + if (!containsDatumCheck) + { + val = CheckDate(ap.StartDate, ap.EndDate); + if (val != null) + { + result.Add(val); + containsDatumCheck = true; + } + } + } + } + } + + } + } + return result; } + private ValidationResultDC CheckDate(DateTime? start, DateTime? end) + { + if (start.HasValue && end.HasValue && start > end) + { + ValidationResultDC resultDc = new ValidationResultDC(); + resultDc.Message = "Das Startdatum darf nicht größer als das Enddatum sein."; + resultDc.AllowSave = false; + return resultDc; + } + return null; + } + public virtual List ValidateSupportConceptDeletion(long supportConceptOid) { var result = new List();