Bugfixes für die Anzeige der Termine im HomeView
Buttons zur Erzeugung und dem Löschen von Testterminen.
This commit is contained in:
@@ -5293,12 +5293,52 @@ namespace BeWo.Service.ServiceImplementations
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Den ersten Buchstaben des Klienten und den Namen des Mitarbeiters speichern, der ihn gelöscht hat. -> Neue Tabelle
|
||||
public void DeleteCustomerForGood(long pCustomerOid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var deletionHistoryEntry = new DeletionHistory();
|
||||
|
||||
var appointments = DAOFactory.SearchDAO.FindAppointmentsForCustomer(pCustomerOid);
|
||||
var customer = DAOFactory.GenericDAO.LoadByID<Customer>(pCustomerOid);
|
||||
var supportConceptOids = customer.SupportConcepts.Select(sc => sc.Oid.Value).ToList();
|
||||
|
||||
UserDC user;
|
||||
if (LoggedInUserOperationContextExt.Current != null && LoggedInUserOperationContextExt.Current.User != null)
|
||||
{
|
||||
user = MapperFactory.UserDC_User.MapToNewDC(LoggedInUserOperationContextExt.Current.User);
|
||||
}
|
||||
else
|
||||
{
|
||||
user = MapperFactory.UserDC_User.MapToNewDC(SessionFacade.LoggedInUser);
|
||||
}
|
||||
|
||||
if(user != null)
|
||||
{
|
||||
string initial;
|
||||
|
||||
if(customer.Person.FirstName.Length > 0)
|
||||
{
|
||||
initial = customer.Person.FirstName[0].ToString();
|
||||
}
|
||||
else if(customer.Person.LastName.Length > 0)
|
||||
{
|
||||
initial = customer.Person.LastName[0].ToString();
|
||||
}
|
||||
else if(customer.CustomerAlias?.Length > 0)
|
||||
{
|
||||
initial = customer.CustomerAlias[0].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
initial = "unbekannt";
|
||||
}
|
||||
|
||||
deletionHistoryEntry.DeletingEmployeeName = $"{user.Employee.FirstName} {user.Employee.LastName}";
|
||||
deletionHistoryEntry.DeletedEntityName = initial;
|
||||
deletionHistoryEntry.DeletedEntityTableId = TableID.Customer;
|
||||
}
|
||||
|
||||
appointments.DoForEach(app => app.CustomerList.Remove(customer));
|
||||
|
||||
@@ -5324,6 +5364,23 @@ namespace BeWo.Service.ServiceImplementations
|
||||
|
||||
DAOFactory.GenericDAO.Update(customer.SupportConcepts);
|
||||
|
||||
var additionalServiceGroups = DAOFactory.SearchDAO.GetAdditionalServiceGroupOfPeopleForCustomer(customer.Oid.Value);
|
||||
foreach(var additionalServiceGroup in additionalServiceGroups)
|
||||
{
|
||||
additionalServiceGroup.CustomerList.Remove(customer);
|
||||
}
|
||||
|
||||
DAOFactory.GenericDAO.Update(additionalServiceGroups);
|
||||
|
||||
var additionalServiceBookings = DAOFactory.SearchDAO.GetAllAdditionalServiceBookingsForCustomer(customer.Oid.Value);
|
||||
DAOFactory.GenericDAO.Delete(additionalServiceBookings);
|
||||
|
||||
var images2delete = customer.Person.Images;
|
||||
customer.Person.Images.Clear();
|
||||
|
||||
DAOFactory.GenericDAO.Delete(images2delete);
|
||||
DAOFactory.GenericDAO.Update(customer);
|
||||
|
||||
customer.SupportConcepts.DoForEach(s => s.CostBearer2SupportConceptList?.Clear());
|
||||
foreach(var assessmentSheetCategory in customer.AssessmentSheetCategoryList)
|
||||
{
|
||||
@@ -5331,7 +5388,33 @@ namespace BeWo.Service.ServiceImplementations
|
||||
}
|
||||
|
||||
var assessmentSheetEntries = DAOFactory.SearchDAO.GetAssessmentSheetEntriesForCustomer(customer.Oid.Value, DateTime.MinValue, DateTime.MaxValue);
|
||||
|
||||
|
||||
var invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
|
||||
invoiceBases2Delete.DoForEach(ib => ib.InvoiceItems.Clear());
|
||||
|
||||
var settlementInvoices = DAOFactory.SearchDAO.GetSettlementInvoiceBySupportConceptOids(supportConceptOids);
|
||||
var serviceInvoices = DAOFactory.SearchDAO.GetServiceInvoicesByInvoiceBaseOids(invoiceBases2Delete.Select(s => s.Oid.Value).ToList());
|
||||
|
||||
var invoiceItems = new List<InvoiceItem>();
|
||||
invoiceBases2Delete.DoForEach(ib => invoiceItems.AddRange(ib.InvoiceItems));
|
||||
DAOFactory.GenericDAO.Update(invoiceBases2Delete);
|
||||
|
||||
if(supportConceptOids.Any())
|
||||
{
|
||||
var tasksAndAppointments2Delete = DAOFactory.SearchDAO.GetTasksAndAppointmentsBySupportConceptOids(supportConceptOids);
|
||||
DAOFactory.GenericDAO.Delete(tasksAndAppointments2Delete);
|
||||
}
|
||||
|
||||
DAOFactory.GenericDAO.Delete(invoiceItems);
|
||||
DAOFactory.GenericDAO.Delete(settlementInvoices);
|
||||
DAOFactory.GenericDAO.Delete(serviceInvoices);
|
||||
|
||||
invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
|
||||
DAOFactory.GenericDAO.Delete(invoiceBases2Delete);
|
||||
|
||||
var customer2Tokens2Delete = DAOFactory.SearchDAO.GetCustomer2TokensByCustomerOid(customer.Oid.Value);
|
||||
DAOFactory.GenericDAO.Delete(customer2Tokens2Delete);
|
||||
|
||||
DAOFactory.GenericDAO.Delete(assessmentSheetEntries);
|
||||
|
||||
DAOFactory.GenericDAO.Update(customer);
|
||||
@@ -5339,6 +5422,11 @@ namespace BeWo.Service.ServiceImplementations
|
||||
DAOFactory.GenericDAO.Delete(customer.SupportConcepts);
|
||||
|
||||
DAOFactory.GenericDAO.Delete(DAOFactory.GenericDAO.LoadByID<Customer>(customer.Oid.Value));
|
||||
|
||||
if(deletionHistoryEntry.DeletingEmployeeName != null)
|
||||
{
|
||||
DAOFactory.GenericDAO.Insert(deletionHistoryEntry);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user