Files
BeWoPlaner/ReportImp/SeWo/Service/CustomHomeContentGenerator.cs
Christian 9c97d6fe79 CB Merge
2019-07-12 17:36:37 +02:00

85 lines
3.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BeWo.Service.Plugins;
using BS.Shared.DataContracts.Compact;
using DevExpress.Data.Helpers;
namespace SeWo.Service
{
class CustomHomeContentGenerator : HomeContentGenerator
{
public override List<CompactSupportConceptDC> GetExpiringSupportConcepts(long? employeeOid, DateTime expiredUntil)
{
List<CompactSupportConceptDC> result = new List<CompactSupportConceptDC>();
var list = DAOFactory.SearchDAO.FindExpiringSupportConcepts(employeeOid, DateTime.Now.Date, expiredUntil);
foreach (var sc in list)
{
foreach (var c2s in sc.CostBearer2SupportConceptList)
{
if (c2s.ApprovedEndDate.HasValue && c2s.ApprovedEndDate.Value >= DateTime.Now.Date &&
c2s.ApprovedEndDate.Value <= expiredUntil)
{
result.Add(CreateCompactSupportConceptDC(sc, c2s));
}
}
}
return result.Where(s => s.StartDate.HasValue && s.EndDate.HasValue).ToList();
}
private CompactSupportConceptDC CreateCompactSupportConceptDC(SupportConcept sc, CostBearer2SupportConcept c2S)
{
var dc = new CompactSupportConceptDC();
dc.SupportConceptOid = sc.Oid.Value;
dc.SupportConceptVersion = sc.Version.Value;
dc.Customer = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(sc.Customer);
dc.ActivationType = sc.IsActive;
dc.ConferenceDate = sc.ConferenceDate;
CompactCostBearerDC costBearer = new CompactCostBearerDC();
if (c2S.CostBearer.Organisation != null)
{
CompactOrganisationDC orgDC = new CompactOrganisationDC();
orgDC.Name = c2S.CostBearer.Organisation.Name;
orgDC.OrganisationOid = c2S.CostBearer.Organisation.Oid.Value;
costBearer.Organisation = orgDC;
dc.Customer.FirstName = dc.Customer.FirstName + ", " + orgDC.Name;
}
costBearer.CostBearerID = c2S.CostBearer.ID;
costBearer.CostBearerOid = c2S.CostBearer.Oid.Value;
costBearer.CostBearer2SupportConceptOid = c2S.Oid.Value;
costBearer.SupportConceptStatus = c2S.Status;
costBearer.RequestedStartDate = c2S.RequestedStartDate;
costBearer.RequestedEndDate = c2S.RequestedEndDate;
costBearer.ApprovedStartDate = c2S.ApprovedStartDate;
costBearer.ApprovedEndDate = c2S.ApprovedEndDate;
costBearer.CustomerReferenceNumber = c2S.CustomerReferenceNumber;
costBearer.IsCalculatingWithFactor = c2S.CostBearer.IsCalculatingWithFactor;
dc.IsApproved = c2S.ApprovedStartDate.HasValue && c2S.ApprovedEndDate.HasValue;
dc.CostBearerList.Add(costBearer);
dc.CostBearerOids2CostBearerRelOids.Add(costBearer.Oid.Value, c2S.Oid.Value);
dc.CustomerReferenceNumbers.Add(c2S.CustomerReferenceNumber);
dc.CostBearerRelOids.Add(c2S.Oid.Value);
return dc;
}
}
}