using System;

using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class MailReceiverDC_Mail2Receiver : AbstractIDCEntityMapper<Mail2Receiver, MailReceiverDC>
    {
        public override MailReceiverDC MergeWithDC(Mail2Receiver pEntity, MailReceiverDC pDataContract)
        {
            pDataContract.Mail2ReceiverOid = pEntity.Oid.Value;
            if (pEntity.Receiver != null)
            {
                pDataContract.FirstName = pEntity.Receiver.Person.FirstName;
                pDataContract.LastName = pEntity.Receiver.Person.LastName;
                pDataContract.EmployeeOid = pEntity.Receiver.Oid;
            }

            pDataContract.EmailAddress = pEntity.ReceiverEMailAddress;

            return pDataContract;
        }

        public override Mail2Receiver MergeWithEntity(MailReceiverDC pDataContract, Mail2Receiver pEntity)
        {
            throw new NotImplementedException();
        }

        protected override bool AreDCAndEntityEqual(MailReceiverDC pDC, Mail2Receiver pEntity)
        {
            if (pDC.Mail2ReceiverOid == null)
            {
                return false;
            }

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