using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class MandatorDC_Mandator : AbstractIDCEntityMapper<Mandator, MandatorDC>
    {
        public override MandatorDC MergeWithDC(Mandator pEntity, MandatorDC pDataContract)
        {
            pDataContract.MandatorOid = pEntity.Oid;
            pDataContract.MandatorVersion = pEntity.Version;
            pDataContract.Name = pEntity.Name;
            pDataContract.ClientId = pEntity.ClientId;
            pDataContract.BeWoClientType = pEntity.BeWoClientType;
            pDataContract.Country = pEntity.Country;
            pDataContract.State = pEntity.State;
            pDataContract.Town = pEntity.Town;
            pDataContract.PostalCode = pEntity.PostalCode;
            pDataContract.Street = pEntity.Street;
            pDataContract.Settings = pEntity.Settings;
			pDataContract.RssFeedUrl = pEntity.RssFeedUrl;
			pDataContract.IsSchedulerAllowed = pEntity.IsSchedulerAllowed;
			pDataContract.IsMedicationAllowed = pEntity.IsMedicationAllowed;

            return pDataContract;
        }

        public override Mandator MergeWithEntity(MandatorDC pDataContract, Mandator pEntity)
        {
            this.ConcurrencyCheck(pDataContract.MandatorVersion, pEntity);

            pEntity.Name = pDataContract.Name;
            pEntity.ClientId = pDataContract.ClientId;
            pEntity.BeWoClientType = pDataContract.BeWoClientType;
            pEntity.Country = pDataContract.Country;
            pEntity.State = pDataContract.State;
            pEntity.Town = pDataContract.Town;
            pEntity.PostalCode = pDataContract.PostalCode;
            pEntity.Street = pDataContract.Street;
            pEntity.Settings = pDataContract.Settings;
			pEntity.RssFeedUrl = pDataContract.RssFeedUrl;
			pEntity.IsSchedulerAllowed = pDataContract.IsSchedulerAllowed;
			pEntity.IsMedicationAllowed = pDataContract.IsMedicationAllowed;

            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(MandatorDC pDC, Mandator pEntity)
        {
            if (pDC.MandatorOid == null)
            {
                return false;
            }

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