Files
BeWoPlaner/Report/ReportObjects/EmployeeCustomerListRO.cs
Christian 8184426879 cb
2022-02-22 11:58:42 +01:00

65 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Data.ICD10;
using BeWo.Service.DCEntityMapper;
using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
namespace BeWo.Report.ReportObjects
{
public class EmployeeCustomerListRO : AbstractBeWoReportObject<EmployeeCustomerListRO>
{
public EmployeeDC Employee { get; set; }
public IList<Employee2CustomerDetail> CustomerList { get; set; }
public static EmployeeCustomerListRO Create(long? employeeOid)
{
var emp = DAOFactory.GenericDAO.LoadByID<Employee>(employeeOid.Value);
var empDc = MapperFactory.EmployeeDC_Employee.MapToNewDC(emp);
var result = new EmployeeCustomerListRO();
result.Employee = empDc;
result.CustomerList = new List<Employee2CustomerDetail>();
foreach (var e2c in emp.Employee2CustomerList)
{
if (e2c.Customer.IsActive == ActivationTypeId.Active)
{
Employee2CustomerDetail e2cDetail = new Employee2CustomerDetail();
e2cDetail.Notiz = e2c.Notice;
foreach (var v2o in e2c.ValueList)
{
if (v2o.Entry.Type == ValueListEntryType.StaffRoleType)
{
e2cDetail.Rolle = v2o.Entry.Value;
}
}
e2cDetail.Customer = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(e2c.Customer);
result.CustomerList.Add(e2cDetail);
}
}
//result.Notice = pDC.Notice;
result.CustomerList = result.CustomerList.OrderBy(c => c.Customer.LastNameFirstName).ToList();
return result;
}
}
public class Employee2CustomerDetail
{
public String Rolle { get; set; }
public String Notiz { get; set; }
public CompactCustomerDC Customer { get; set; }
}
}