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

namespace BeWo.Service.DCEntityMapper
{
    public class SupportPinDC_SupportPin : AbstractIDCEntityMapper<SupportPin, SupportPinDC>
    {
        public override SupportPinDC MergeWithDC(SupportPin pEntity, SupportPinDC pDataContract)
        {
            pDataContract.SupportPinOid = pEntity.Oid;
            pDataContract.SupportPinVersion = pEntity.Version;
            pDataContract.Pin = pEntity.Pin;
            pDataContract.IsUsed = pEntity.IsUsed;
            pDataContract.CreationDate = pEntity.CreationDate;
            pDataContract.ExpirationDate = pEntity.ExpirationDate;
            pDataContract.UsingDate = pEntity.UsingDate;

            return pDataContract;
        }

        public override SupportPin MergeWithEntity(SupportPinDC pDataContract, SupportPin pEntity)
        {
            ConcurrencyCheck(pDataContract.SupportPinVersion, pEntity);

            pEntity.Oid = pDataContract.SupportPinOid;
            pEntity.Pin = pDataContract.Pin;
            pEntity.IsUsed = pDataContract.IsUsed;
            pEntity.CreationDate = pDataContract.CreationDate;
            pEntity.ExpirationDate = pDataContract.ExpirationDate;
            pEntity.UsingDate = pDataContract.UsingDate;

            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(SupportPinDC pDC, SupportPin pEntity)
        {
            if (pDC.SupportPinOid == null)
                return false;

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