using System;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;

namespace BeWo.Service.DCEntityMapper
{
	public class BeWoMobilBrowserInfoDC_BeWoMobilBrowserInfo : AbstractIDCEntityMapper<BeWoMobilBrowserInfo, BeWoMobilBrowserInfoDC>
	{
		public override BeWoMobilBrowserInfoDC MergeWithDC(BeWoMobilBrowserInfo pEntity, BeWoMobilBrowserInfoDC pDataContract)
		{
			pDataContract.BeWoMobilBrowserInfoOid = pEntity.Oid;
			pDataContract.Type = pEntity.Type;
			pDataContract.Tenant = pEntity.Tenant;
			pDataContract.Platform = pEntity.Platform;
			pDataContract.Name = pEntity.Name;
			pDataContract.BrowserVersion = pEntity.BrowserVersion;

			return pDataContract;
		}

		public override BeWoMobilBrowserInfo MergeWithEntity(BeWoMobilBrowserInfoDC pDataContract, BeWoMobilBrowserInfo pEntity)
		{
			pEntity.Oid = pDataContract.BeWoMobilBrowserInfoOid;

			if(pEntity.InsTs == null)
				pEntity.InsTs = DateTime.Now;

			pEntity.Type = pDataContract.Type;
			pEntity.Tenant = pDataContract.Tenant;
			pEntity.Platform = pDataContract.Platform;
			pEntity.Name = pDataContract.Name;
			pEntity.BrowserVersion = pDataContract.BrowserVersion;

			return pEntity;
		}

		protected override bool AreDCAndEntityEqual(BeWoMobilBrowserInfoDC pDC, BeWoMobilBrowserInfo pEntity)
		{
			if (pDC.BeWoMobilBrowserInfoOid == null)
				return false;

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