using BeWo.Data.Entities;

using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
	public class UiElementDC_UiElement : AbstractIDCEntityMapper<UiElement, UiElementDC>
	{
		public override UiElementDC MergeWithDC(UiElement pEntity, UiElementDC pDataContract)
		{
			pDataContract.Oid = pEntity.Oid;
			pDataContract.Version = pEntity.Version;
			pDataContract.UiElementType = pEntity.UiElementType;
			pDataContract.Xaml = pEntity.Xaml;
			pDataContract.EmployeeOid = pEntity.EmployeeOid;
			pDataContract.TeamOid = pEntity.TeamOid;

			return pDataContract;
		}

		public override UiElement MergeWithEntity(UiElementDC pDataContract, UiElement pEntity)
		{
			ConcurrencyCheck(pDataContract.Version, pEntity);

			pEntity.Oid = pDataContract.Oid;
			pEntity.UiElementType = pDataContract.UiElementType;
			pEntity.Xaml = pDataContract.Xaml;
			pEntity.EmployeeOid = pDataContract.EmployeeOid;
			pEntity.TeamOid = pDataContract.TeamOid;

			return pEntity;
		}

		protected override bool AreDCAndEntityEqual(UiElementDC pDC, UiElement pEntity)
		{
			if (pDC.Oid == null)
				return false;

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