using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class ContactDC_Contact : AbstractIDCEntityMapper<Contact, ContactDC>
    {
        public override ContactDC MergeWithDC(Contact pEntity, ContactDC pDataContract)
        {
            pDataContract.ContactOID = pEntity.Oid;
            pDataContract.ContactValue = pEntity.Value;
            pDataContract.ContactVersion = pEntity.Version;
            pDataContract.ContactType = pEntity.Type;
            return pDataContract;
        }

        public override Contact MergeWithEntity(ContactDC pDataContract, Contact pEntity)
        {
            this.ConcurrencyCheck(pDataContract.ContactVersion, pEntity);

            pEntity.Oid = pDataContract.ContactOID;
            pEntity.Value = pDataContract.ContactValue;
            pEntity.Type = pDataContract.ContactType;
            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(ContactDC pDC, Contact pEntity)
        {
            if (pDC.ContactOID == null)
            {
                return false;
            }

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