using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
    public class AbsenceReasonDC_AbsenceReason : AbstractIDCEntityMapper<AbsenceReason, AbsenceReasonDC>
    {
        public override AbsenceReasonDC MergeWithDC(AbsenceReason pEntity, AbsenceReasonDC pDataContract)
        {
            pDataContract.AbsenceReasonOid = pEntity.Oid;
            pDataContract.AbsenceReasonVersion = pEntity.Version;
            pDataContract.Description = pEntity.Description;
            pDataContract.BillableMinutes = pEntity.BillableMinutes;
            pDataContract.IsSystemEntry = pEntity.SystemEntryID != null;
            pDataContract.Color = pEntity.Color;

            return pDataContract;
        }

        public override AbsenceReason MergeWithEntity(AbsenceReasonDC pDataContract, AbsenceReason pEntity)
        {
            this.ConcurrencyCheck(pDataContract.AbsenceReasonVersion, pEntity);

            pEntity.Oid = pDataContract.AbsenceReasonOid;
            pEntity.Description = pDataContract.Description;
            pEntity.BillableMinutes = pDataContract.BillableMinutes;
            pEntity.Color = pDataContract.Color;

            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(AbsenceReasonDC pDC, AbsenceReason pEntity)
        {
            if (pDC.AbsenceReasonOid == null)
            {
                return false;
            }

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