From bcc8379fe6ec0a5555e0f226b60a82556250fc67 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Mon, 28 May 2018 14:39:28 +0200 Subject: [PATCH] =?UTF-8?q?Das=20endg=C3=BCltige=20L=C3=B6schen=20von=20Kl?= =?UTF-8?q?ienten=20ist=20jetzt=20implementiert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OperationsServiceImp.cs | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/Service/ServiceImplementations/OperationsServiceImp.cs b/Service/ServiceImplementations/OperationsServiceImp.cs index aa880ae72..47ef796cf 100644 --- a/Service/ServiceImplementations/OperationsServiceImp.cs +++ b/Service/ServiceImplementations/OperationsServiceImp.cs @@ -5190,46 +5190,50 @@ namespace BeWo.Service.ServiceImplementations private int _AbWelchemKrankheitsTag; private bool _VertretungDringendErforderlich; */ - - - //var appointments = DAOFactory.SearchDAO.FindAppointmentsForCustomer(pCustomerOid); - //var customer = DAOFactory.GenericDAO.LoadByID(pCustomerOid); - //appointments.DoForEach(app => app.CustomerList.Remove(customer)); + + var appointments = DAOFactory.SearchDAO.FindAppointmentsForCustomer(pCustomerOid); + var customer = DAOFactory.GenericDAO.LoadByID(pCustomerOid); + + appointments.DoForEach(app => app.CustomerList.Remove(customer)); + + DAOFactory.GenericDAO.Update(appointments); + + var costBearer2SupportConcepts = new List(); + var groupsToGetReferencesRemoved = new List(); + foreach(var sc in customer.SupportConcepts) + { + foreach(var cb2sc in sc.CostBearer2SupportConceptList) + { + groupsToGetReferencesRemoved.AddRangeIfElementsNotIn(DAOFactory.SearchDAO.GroupOfPeopleForSupportConcept(cb2sc.Oid.Value)); + costBearer2SupportConcepts.AddIfNotIn(cb2sc); + } + } + + foreach(var group in groupsToGetReferencesRemoved) + { + group.CostBearer2SupportConceptList.RemoveRange(costBearer2SupportConcepts); + } + + DAOFactory.GenericDAO.Update(groupsToGetReferencesRemoved); + + DAOFactory.GenericDAO.Update(customer.SupportConcepts); + + customer.SupportConcepts.DoForEach(s => s.CostBearer2SupportConceptList?.Clear()); + foreach(var assessmentSheetCategory in customer.AssessmentSheetCategoryList) + { + assessmentSheetCategory.Customers.Remove(customer); + } + + var assessmentSheetEntries = DAOFactory.SearchDAO.GetAssessmentSheetEntriesForCustomer(customer.Oid.Value, DateTime.MinValue, DateTime.MaxValue); - //DAOFactory.GenericDAO.Update(appointments); - - //var costBearer2SupportConcepts = new List(); - //var groupsToGetReferencesRemoved = new List(); - //foreach(var sc in customer.SupportConcepts) - //{ - // foreach(var cb2sc in sc.CostBearer2SupportConceptList) - // { - // groupsToGetReferencesRemoved.AddRangeIfElementsNotIn(DAOFactory.SearchDAO.GroupOfPeopleForSupportConcept(cb2sc.Oid.Value)); - // costBearer2SupportConcepts.AddIfNotIn(cb2sc); - // } - //} - - //foreach(var group in groupsToGetReferencesRemoved) - //{ - // group.CostBearer2SupportConceptList.RemoveRange(costBearer2SupportConcepts); - //} + DAOFactory.GenericDAO.Delete(assessmentSheetEntries); - //DAOFactory.GenericDAO.Update(groupsToGetReferencesRemoved); - - //DAOFactory.GenericDAO.Update(customer.SupportConcepts); + DAOFactory.GenericDAO.Update(customer); - //customer.SupportConcepts.DoForEach(s => s.CostBearer2SupportConceptList?.Clear()); - //foreach(var assessmentSheetCategory in customer.AssessmentSheetCategoryList) - //{ - - //} + DAOFactory.GenericDAO.Delete(customer.SupportConcepts); - //DAOFactory.GenericDAO.Update(customer); - - //DAOFactory.GenericDAO.Delete(customer.SupportConcepts); - - //DAOFactory.GenericDAO.Delete(customer); + DAOFactory.GenericDAO.Delete(DAOFactory.GenericDAO.LoadByID(customer.Oid.Value)); } catch(Exception e) {