using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class SettingsDC_Settings : AbstractIDCEntityMapper<Settings, SettingsDC>
    {
        public override SettingsDC MergeWithDC(Settings pEntity, SettingsDC pDataContract)
        {
            pDataContract.SettingsOid = pEntity.Oid;
            pDataContract.Type = pEntity.Type;
            pDataContract.Value = pEntity.Value;
            pDataContract.SettingsVersion = pEntity.Version;

            return pDataContract;
        }

        public override Settings MergeWithEntity(SettingsDC pDataContract, Settings pEntity)
        {
            this.ConcurrencyCheck(pDataContract.SettingsVersion, pEntity);

            pEntity.Oid = pDataContract.SettingsOid;
            pEntity.Type = pDataContract.Type;
            pEntity.Value = pDataContract.Value;

            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(SettingsDC pDC, Settings pEntity)
        {
            if (pDC.SettingsOid == null)
            {
                return false;
            }

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