Files
BeWoPlaner/Service/DCEntityMapper/WohnheimEmployeeRelDC_Employee2WohnheimMapper.cs

52 lines
1.9 KiB
C#

using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.DataContracts;
namespace BeWo.Service.DCEntityMapper
{
public class WohnheimEmployeeRelDC_Employee2WohnheimMapper : AbstractIDCEntityMapper<Employee2Wohnheim, WohnheimEmployeeRelationDC>
{
public override WohnheimEmployeeRelationDC MergeWithDC(Employee2Wohnheim pEntity, WohnheimEmployeeRelationDC pDataContract)
{
pDataContract.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Employee);
pDataContract.Wohnheim = MapperFactory.CompactWohnheimDC_Wohnheim.MapToNewDC(pEntity.Wohnheim);
pDataContract.Employee2WohnheimOid = pEntity.Oid;
pDataContract.Employee2WohnheimVersion = pEntity.Version;
pDataContract.Notice = pEntity.Notice;
return pDataContract;
}
public override Employee2Wohnheim MergeWithEntity(WohnheimEmployeeRelationDC pDataContract, Employee2Wohnheim pEntity)
{
this.ConcurrencyCheck(pDataContract.Employee2WohnheimVersion, pEntity);
if (pDataContract.Employee != null)
{
pEntity.Employee = DAOFactory.GenericDAO.LoadByID<Employee>(pDataContract.Employee.EmployeeOid);
}
if (pDataContract.Wohnheim != null)
{
pEntity.Wohnheim = DAOFactory.GenericDAO.LoadByID<Wohnheim>(pDataContract.Wohnheim.WohnheimOid);
}
pEntity.Oid = pDataContract.Employee2WohnheimOid;
pEntity.Notice = pDataContract.Notice;
return pEntity;
}
protected override bool AreDCAndEntityEqual(WohnheimEmployeeRelationDC pDC, Employee2Wohnheim pEntity)
{
if (pDC.Employee2WohnheimOid == null)
{
return false;
}
return pDC.Employee2WohnheimOid == pEntity.Oid;
}
}
}