using BS.Shared.DataContracts;
using BeWo.Data.Entities;

namespace BeWo.Service.DCEntityMapper
{
    public class AdditionalServiceDC_AdditionalService : AbstractIDCEntityMapper<AdditionalService, AdditionalServiceDC>
    {
        public override AdditionalServiceDC MergeWithDC(AdditionalService pEntity, AdditionalServiceDC pDataContract)
        {
            pDataContract.AdditionalServiceOid = pEntity.Oid;
            pDataContract.AdditionalServiceVersion = pEntity.Version;
            pDataContract.InsertedOn = pEntity.InsTs;
            pDataContract.InsUser = pEntity.InsUser;
            pDataContract.Notice = pEntity.Notice;
            pDataContract.Name = pEntity.Name;

            return pDataContract;
        }

        public override AdditionalService MergeWithEntity(AdditionalServiceDC pDataContract, AdditionalService pEntity)
        {
            ConcurrencyCheck(pDataContract.AdditionalServiceVersion, pEntity);

            pEntity.Oid = pDataContract.AdditionalServiceOid;
            pEntity.Notice = pDataContract.Notice;
            pEntity.Name = pDataContract.Name;

            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(AdditionalServiceDC pDC, AdditionalService pEntity)
        {
            if (pDC.AdditionalServiceOid == null)
                return false;

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