using System;
using System.Collections.Generic;
using System.Linq;

using BeWo.Data.Entities;
using BeWo.Service.Core;

using BS.Shared.DataContracts;

using Utils = BS.Shared.Core.Utils;

namespace BeWo.Service.DCEntityMapper
{
    public class EmploymentTypeDC_EmploymentType : AbstractIDCEntityMapper<EmploymentType, EmploymentTypeDC>
    {
        public override EmploymentTypeDC MergeWithDC(EmploymentType pEntity, EmploymentTypeDC pDataContract)
        {
            pDataContract.EmploymentTypeVersion = pEntity.Version;
            pDataContract.EmploymentTypeOid = pEntity.Oid;
            pDataContract.Name = pEntity.Name;

            return pDataContract;
        }

        public override EmploymentType MergeWithEntity(EmploymentTypeDC pDataContract, EmploymentType pEntity)
        {
            this.ConcurrencyCheck(pDataContract.EmploymentTypeVersion, pEntity);

            pEntity.Oid = pDataContract.EmploymentTypeOid;
            pEntity.Name = pDataContract.Name;
            
            return pEntity;
        }

        protected override bool AreDCAndEntityEqual(EmploymentTypeDC pDC, EmploymentType pEntity)
        {
            if (pDC.EmploymentTypeOid == null)
            {
                return false;
            }

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