From 48980831178c92b2525da77ce7d012d59bdd32be Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 10 Mar 2026 00:24:45 +0100 Subject: [PATCH] =?UTF-8?q?Pr=C3=BCfung=20ob=20Startdatum=20>=20Enddatum?= =?UTF-8?q?=20eingetragen=20wurde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Plugins/SupportConceptValidator.cs | 52 +++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) 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();