Files
BeWoPlaner/Service/DCEntityMapper/CustomerTokenRelationDC_Customer2Token.cs
2017-06-30 13:33:49 +02:00

48 lines
1.7 KiB
C#

using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared;
using BS.Shared.DataContracts;
namespace BeWo.Service.DCEntityMapper
{
public class CustomerTokenRelationDC_Customer2Token : AbstractIDCEntityMapper<Customer2Token, CustomerTokenRelationDC>
{
public override CustomerTokenRelationDC MergeWithDC(Customer2Token pEntity, CustomerTokenRelationDC pDataContract)
{
//pDataContract.Customer2TokenNotice = pEntity.Notice;
pDataContract.Customer2TokenOid = pEntity.Oid;
pDataContract.Token = MapperFactory.CompactTokenDC_Token.MapToNewDC(pEntity.Token);
pDataContract.Customer = MapperFactory.CustomerDC_Customer.MapToNewDC(pEntity.Customer);
return pDataContract;
}
public override Customer2Token MergeWithEntity(CustomerTokenRelationDC pDataContract, Customer2Token pEntity)
{
pEntity.Oid = pDataContract.Customer2TokenOid;
if (pDataContract.Token != null){
pEntity.Token = DAOFactory.GenericDAO.LoadByID<Token>(pDataContract.Token.TokenOid.Value);
}
if (pDataContract.Customer != null)
{
pEntity.Customer = DAOFactory.GenericDAO.LoadByID<Customer>(pDataContract.Customer.CustomerOid.Value);
}
return pEntity;
}
protected override bool AreDCAndEntityEqual(CustomerTokenRelationDC pDC, Customer2Token pEntity)
{
if (pDC.Customer2TokenOid == null)
{
return false;
}
return pDC.Customer2TokenOid == pEntity.Oid;
}
}
}