using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class ServiceRecordGroupDC_ServiceRecordGroup : AbstractIDCEntityMapper<ServiceRecordGroup, ServiceRecordGroupDC>
    {
        public override ServiceRecordGroupDC MergeWithDC(ServiceRecordGroup pEntity, ServiceRecordGroupDC pDataContract)
        {
            pDataContract.ServiceRecordGroupOid = pEntity.Oid;
            pDataContract.ServiceRecordGroupVersion = pEntity.Version;
            pDataContract.StartDate = pEntity.StartDate;
            pDataContract.EndDate = pEntity.EndDate;
            pDataContract.Notice = pEntity.Notice;
            pDataContract.Notice2 = pEntity.Notice2;
            pDataContract.Notice3 = pEntity.Notice3;
            pDataContract.Notice4 = pEntity.Notice4;
            pDataContract.Notice5 = pEntity.Notice5;
            pDataContract.RoundedDuration = pEntity.RoundedDuration;
            pDataContract.EmployeeCount = pEntity.EmployeeCount;
            pDataContract.CustomerCount = pEntity.CustomerCount;

            return pDataContract;
        }

        public override ServiceRecordGroup MergeWithEntity(ServiceRecordGroupDC pDataContract, ServiceRecordGroup pEntity)
        {
            this.ConcurrencyCheck(pDataContract.ServiceRecordGroupVersion, pEntity);

            pEntity.Oid = pDataContract.ServiceRecordGroupOid;
            pEntity.Notice = pDataContract.Notice;
            pEntity.Notice2 = pDataContract.Notice2;
            pEntity.Notice3 = pDataContract.Notice3;
            pEntity.Notice4 = pDataContract.Notice4;
            pEntity.Notice5 = pDataContract.Notice5;
            pEntity.StartDate = pDataContract.StartDate;
            pEntity.EndDate = pDataContract.EndDate;
            pEntity.RoundedDuration = pDataContract.RoundedDuration;
            pEntity.EmployeeCount = pDataContract.EmployeeCount;
            pEntity.CustomerCount = pDataContract.CustomerCount;

            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(ServiceRecordGroupDC pDC, ServiceRecordGroup pEntity)
        {
            if (pDC.ServiceRecordGroupOid == null)
            {
                return false;
            }

            return pDC.ServiceRecordGroupOid == pEntity.Oid;
        }
    }
}