using BeWo.Data.Access; using BeWo.Data.Entities; using BS.Shared; using BS.Shared.DataContracts; namespace BeWo.Service.DCEntityMapper { public class CustomerEmployeeRelDC_Employee2CustomerMapper : AbstractIDCEntityMapper { public override CustomerEmployeeRelationDC MergeWithDC(Employee2Customer pEntity, CustomerEmployeeRelationDC pDataContract) { if (pEntity.ValueList.Count > 0) { pDataContract.RelationRole = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDC(pEntity.ValueList[0].Entry); } pDataContract.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Employee); pDataContract.Customer = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(pEntity.Customer); pDataContract.Employee2CustomerOid = pEntity.Oid; pDataContract.Employee2CustomerVersion = pEntity.Version; pDataContract.Notice = pEntity.Notice; pDataContract.Chatpartner = pEntity.Chatpartner; pDataContract.StartDate = pEntity.StartDate; pDataContract.EndDate = pEntity.EndDate; return pDataContract; } public override Employee2Customer MergeWithEntity(CustomerEmployeeRelationDC pDataContract, Employee2Customer pEntity) { this.ConcurrencyCheck(pDataContract.Employee2CustomerVersion, pEntity); MapperFactory.ValueListEntryDC_ValueListEntry.MapUniqueTypeValueListEntryBack2Entity(pDataContract.RelationRole, pEntity.ValueList, ValueListEntryType.StaffRoleType, TableID.Employee2Customer); if (pDataContract.Employee != null) { pEntity.Employee = DAOFactory.GenericDAO.LoadByID(pDataContract.Employee.EmployeeOid); } if (pDataContract.Customer != null) { pEntity.Customer = DAOFactory.GenericDAO.LoadByID(pDataContract.Customer.CustomerOid); } pEntity.Oid = pDataContract.Employee2CustomerOid; pEntity.Notice = pDataContract.Notice; pEntity.Chatpartner = pDataContract.Chatpartner; pEntity.StartDate = pDataContract.StartDate; pEntity.EndDate = pDataContract.EndDate; return pEntity; } protected override bool AreDCAndEntityEqual(CustomerEmployeeRelationDC pDC, Employee2Customer pEntity) { if (pDC.Employee2CustomerOid == null) { return false; } return pDC.Employee2CustomerOid == pEntity.Oid; } } }