using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class AppointmentCategoryDC_AppointmentCategory : AbstractIDCEntityMapper<AppointmentCategory, AppointmentCategoryDC>
    {
        public override AppointmentCategoryDC MergeWithDC(AppointmentCategory pEntity, AppointmentCategoryDC pDataContract)
        {
            pDataContract.AppointmentCategoryOid = pEntity.Oid;
            pDataContract.AppointmentCategoryVersion = pEntity.Version;
            pDataContract.DisplayName = pEntity.DisplayName;
            pDataContract.Color = pEntity.Color;

            return pDataContract;
        }

        public override AppointmentCategory MergeWithEntity(AppointmentCategoryDC pDataContract, AppointmentCategory pEntity)
        {
            this.ConcurrencyCheck(pDataContract.AppointmentCategoryVersion, pEntity);

            pEntity.Oid = pDataContract.AppointmentCategoryOid;
            pEntity.DisplayName = pDataContract.DisplayName;
            pEntity.Color = pDataContract.Color;

            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(AppointmentCategoryDC pDC, AppointmentCategory pEntity)
        {
            if (pDC.AppointmentCategoryOid == null)
            {
                return false;
            }

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