using BeWo.Data.Access; using BeWo.Data.Entities; using BS.Shared.DataContracts; namespace BeWo.Service.DCEntityMapper { public class TextModuleDC_TextModule : AbstractIDCEntityMapper { 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; pDataContract.IsExpanded = pEntity.IsExpanded; pDataContract.ActivationType = pEntity.IsActive; pDataContract.Parent = pEntity.Parent != null ? MapperFactory.TextModuleDC_TextModule.MapToNewDC(pEntity.Parent) : null; pDataContract.ServiceCategory = pEntity.ServiceCategory != null ? MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDC(pEntity.ServiceCategory) : null; pDataContract.Employee = pEntity.Employee != null ? MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Employee) : null; 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; pEntity.IsExpanded = pDataContract.IsExpanded; pEntity.IsActive = pDataContract.ActivationType; pEntity.Parent = pDataContract.Parent != null ? DAOFactory.GenericDAO.LoadByID(pDataContract.Parent.TextModuleOid.Value) : null; if(pDataContract.ServiceCategory != null) { pEntity.ServiceCategory = pDataContract.ServiceCategory.ServiceCategoryOid.HasValue ? DAOFactory.GenericDAO.LoadByID(pDataContract.ServiceCategory.ServiceCategoryOid.Value) : MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewEntity(pDataContract.ServiceCategory); } else { pEntity.ServiceCategory = null; } pEntity.Employee = pDataContract.Employee != null ? DAOFactory.GenericDAO.LoadByID(pDataContract.Employee.EmployeeOid) : null; return pEntity; } protected override bool AreDCAndEntityEqual(TextModuleDC pDC, TextModule pEntity) { return pDC.TextModuleOid == pEntity.Oid; } } }