-
This commit is contained in:
75
Service/DCEntityMapper/TextModuleDC_TextModule.cs
Normal file
75
Service/DCEntityMapper/TextModuleDC_TextModule.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
|
||||
using BS.Shared.DataContracts;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public class TextModuleDC_TextModule : AbstractIDCEntityMapper<TextModule, TextModuleDC>
|
||||
{
|
||||
public override TextModuleDC MergeWithDC(TextModule pEntity, TextModuleDC pDataContract)
|
||||
{
|
||||
pDataContract.Position = pEntity.Position;
|
||||
pDataContract.TextModuleVersion = pEntity.Version.Value;
|
||||
pDataContract.TextModuleOid = pEntity.Oid.Value;
|
||||
pDataContract.Text = pEntity.Text;
|
||||
pDataContract.Name = pEntity.Name;
|
||||
pDataContract.IsOnlyForEmployee = pEntity.IsOnlyForEmployee;
|
||||
pDataContract.IsParent = pEntity.IsParent;
|
||||
|
||||
if(pEntity.Parent != null)
|
||||
{
|
||||
pDataContract.Parent = MapperFactory.TextModuleDC_TextModule.MapToNewDC(pEntity.Parent);
|
||||
}
|
||||
|
||||
if(pEntity.ServiceCategory != null)
|
||||
{
|
||||
pDataContract.ServiceCategory = MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDC(pEntity.ServiceCategory);
|
||||
}
|
||||
|
||||
if (pEntity.Employee != null)
|
||||
{
|
||||
pDataContract.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Employee);
|
||||
}
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
public override TextModule MergeWithEntity(TextModuleDC pDataContract, TextModule pEntity)
|
||||
{
|
||||
ConcurrencyCheck(pDataContract.TextModuleVersion, pEntity);
|
||||
|
||||
pEntity.Position = pDataContract.Position;
|
||||
pEntity.Oid = pDataContract.TextModuleOid;
|
||||
pEntity.Text = pDataContract.Text;
|
||||
pEntity.Name = pDataContract.Name;
|
||||
pEntity.IsOnlyForEmployee = pDataContract.IsOnlyForEmployee;
|
||||
pEntity.IsParent = pDataContract.IsParent;
|
||||
|
||||
if(pDataContract.Parent != null)
|
||||
{
|
||||
pEntity.Parent = DAOFactory.GenericDAO.LoadByID<TextModule>(pDataContract.Parent.TextModuleOid.Value);
|
||||
|
||||
}
|
||||
|
||||
if (pDataContract.ServiceCategory != null)
|
||||
{
|
||||
pEntity.ServiceCategory = pDataContract.ServiceCategory.ServiceCategoryOid.HasValue ?
|
||||
DAOFactory.GenericDAO.LoadByID<ServiceCategory>(pDataContract.ServiceCategory.ServiceCategoryOid.Value) :
|
||||
MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewEntity(pDataContract.ServiceCategory);
|
||||
}
|
||||
|
||||
if (pDataContract.Employee != null)
|
||||
{
|
||||
pEntity.Employee = DAOFactory.GenericDAO.LoadByID<Employee>(pDataContract.Employee.EmployeeOid);
|
||||
}
|
||||
|
||||
return pEntity;
|
||||
}
|
||||
|
||||
protected override bool AreDCAndEntityEqual(TextModuleDC pDC, TextModule pEntity)
|
||||
{
|
||||
return pDC.TextModuleOid == pEntity.Oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user