66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BeWo.Service.DCEntityMapper
|
|
{
|
|
public class GoalRatingDC_GoalRating : AbstractIDCEntityMapper<GoalRating, GoalRatingDC>
|
|
{
|
|
public override GoalRatingDC MergeWithDC(GoalRating pEntity, GoalRatingDC pDataContract)
|
|
{
|
|
pDataContract.GoalRatingOid = pEntity.Oid;
|
|
pDataContract.GoalRatingVersion = pEntity.Version;
|
|
pDataContract.Notice = pEntity.Notice;
|
|
|
|
if (pEntity.RatingType != null)
|
|
{
|
|
pDataContract.RatingType = MapperFactory.RatingTypeDC_RatingType.MapToNewDC(pEntity.RatingType);
|
|
}
|
|
if (pEntity.ValueListEntryOid.HasValue)
|
|
{
|
|
pDataContract.GoalEntry = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDC(DAOFactory.GenericDAO.LoadByID<ValueListEntry>(pEntity.ValueListEntryOid.Value));
|
|
}
|
|
return pDataContract;
|
|
}
|
|
|
|
public override GoalRating MergeWithEntity(GoalRatingDC pDataContract, GoalRating pEntity)
|
|
{
|
|
ConcurrencyCheck(pDataContract.GoalRatingVersion, pEntity);
|
|
|
|
pEntity.Oid = pDataContract.GoalRatingOid;
|
|
pEntity.Notice = pDataContract.Notice;
|
|
|
|
if (pDataContract.RatingType == null)
|
|
{
|
|
pEntity.RatingType = null;
|
|
}
|
|
else if (pEntity.RatingType == null || pEntity.RatingType.Oid != pDataContract.RatingType.RatingTypeOid)
|
|
{
|
|
pEntity.RatingType = DAOFactory.GenericDAO.LoadByID<RatingType>(pDataContract.RatingType.RatingTypeOid.Value);
|
|
}
|
|
|
|
if (pDataContract.GoalEntry == null)
|
|
{
|
|
pEntity.ValueListEntryOid = null;
|
|
}
|
|
else
|
|
{
|
|
pEntity.ValueListEntryOid = pDataContract.GoalEntry.ValueListEntryOid;
|
|
}
|
|
|
|
return pEntity;
|
|
}
|
|
|
|
protected override bool AreDCAndEntityEqual(GoalRatingDC pDC, GoalRating pEntity)
|
|
{
|
|
if (pDC.GoalRatingOid == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return pDC.GoalRatingOid == pEntity.Oid;
|
|
}
|
|
}
|
|
} |