using System;

using BeWo.Data.Entities;

using BS.Shared.DataContracts.Compact;

namespace BeWo.Service.DCEntityMapper
{
    public class CompactUserDC_ApplicationUser : AbstractIDCEntityMapper<ApplicationUser, CompactUserDC>
    {
        public override CompactUserDC MergeWithDC(ApplicationUser pEntity, CompactUserDC pDataContract)
        {
            pDataContract.LoginName = pEntity.LoginName;
            pDataContract.UserOid = pEntity.Oid.Value;
            pDataContract.UserVersion = pEntity.Version.Value;
            if (pEntity.Employee != null)
            {
                pDataContract.EmployeeOid = pEntity.Employee.Oid;
                pDataContract.EmployeeFirstName = pEntity.Employee.Person.FirstName;
                pDataContract.EmployeeLastName = pEntity.Employee.Person.LastName;
            }

            return pDataContract;
        }

        public override ApplicationUser MergeWithEntity(CompactUserDC pDataContract, ApplicationUser pEntity)
        {
            // compact is read only
            throw new NotImplementedException();
        }

        protected override bool AreDCAndEntityEqual(CompactUserDC pDC, ApplicationUser pEntity)
        {
            return pDC.UserOid == pEntity.Oid;
        }
    }
}