Files
BeWoPlaner/Service/DCEntityMapper/WohnheimDC_Wohnheim.cs
2016-06-27 01:45:38 +02:00

65 lines
2.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.DataContracts;
namespace BeWo.Service.DCEntityMapper
{
public class WohnheimDC_Wohnheim : AbstractIDCEntityMapper<Wohnheim, WohnheimDC>
{
public override WohnheimDC MergeWithDC(Wohnheim pEntity, WohnheimDC pDataContract)
{
pDataContract.RelatedEmployees = MapperFactory.EmployeeWohnheimRelDC_Employee2WohnheimMapper.MapToNewDCs(pEntity.Employee2WohnheimList);
pDataContract.RelatedCustomers = MapperFactory.CustomerWohnheimRelDC_Customer2WohnheimMapper.MapToNewDCs(pEntity.Customer2WohnheimList);
pDataContract.WohnheimOid = pEntity.Oid;
pDataContract.WohnheimName = pEntity.WohnheimName;
pDataContract.Strasse = pEntity.Strasse;
pDataContract.PLZ = pEntity.PLZ;
pDataContract.Ort = pEntity.Ort;
pDataContract.Bemerkung = pEntity.Bemerkung;
pDataContract.ActivationType = pEntity.IsActive;
return pDataContract;
}
public override Wohnheim MergeWithEntity(WohnheimDC pDataContract, Wohnheim pEntity)
{
pEntity.Oid = pDataContract.WohnheimOid;
pEntity.WohnheimName = pDataContract.WohnheimName;
pEntity.Strasse = pDataContract.Strasse;
pEntity.PLZ = pDataContract.PLZ;
pEntity.Ort = pDataContract.Ort;
pEntity.Bemerkung = pDataContract.Bemerkung;
pEntity.IsActive = pDataContract.ActivationType;
MapperFactory.EmployeeWohnheimRelDC_Employee2WohnheimMapper.MergeWithEntitys(pDataContract.RelatedEmployees, pEntity.Employee2WohnheimList);
// MapperFactory.EmployeeWohnheimRelDC_Employee2WohnheimMapper.MapToNewDCs(pEntity.Employee2WohnheimList);
//MapperFactory.CustomerWohnheimRelDC_Customer2WohnheimMapper.MapToNewDCs(pEntity.Customer2WohnheimList);
MapperFactory.CustomerWohnheimRelDC_Customer2WohnheimMapper.MergeWithEntitys(pDataContract.RelatedCustomers, pEntity.Customer2WohnheimList);
return pEntity;
}
protected override bool AreDCAndEntityEqual(WohnheimDC pDC, Wohnheim pEntity)
{
if (pDC.WohnheimOid == null)
{
return false;
}
return pDC.WohnheimOid == pEntity.Oid;
}
}
}