123 lines
6.8 KiB
C#
123 lines
6.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BeWo.Service.DCEntityMapper
|
|
{
|
|
public class SupportConceptDC_SupportConcept : AbstractIDCEntityMapper<SupportConcept, SupportConceptDC>
|
|
{
|
|
public override SupportConceptDC MergeWithDC(SupportConcept pEntity, SupportConceptDC pDataContract)
|
|
{
|
|
pDataContract.SupportConceptOid = pEntity.Oid;
|
|
pDataContract.SupportConceptVersion = pEntity.Version;
|
|
pDataContract.Conference = pEntity.Conference;
|
|
|
|
pDataContract.ConferenceDate = pEntity.ConferenceDate;
|
|
pDataContract.ApprovalDate = pEntity.ApprovalDate;
|
|
pDataContract.RenewalSendDate = pEntity.RenewalSendDate;
|
|
pDataContract.ConsultingNeeded = pEntity.ConsultingNeeded;
|
|
pDataContract.RequisitionSendDate = pEntity.RequisitionSendDate;
|
|
pDataContract.SupportConceptSendDate = pEntity.SupportConceptSendDate;
|
|
pDataContract.ConferenceVenue = pEntity.ConferenceVenue;
|
|
|
|
pDataContract.Customer = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(pEntity.Customer);
|
|
pDataContract.Notice = pEntity.Notice;
|
|
pDataContract.ActivationType = pEntity.IsActive;
|
|
if (pEntity.Originator != null)
|
|
{
|
|
pDataContract.Originator = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Originator);
|
|
}
|
|
|
|
pDataContract.CostBearerRelations = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDCs(pEntity.CostBearer2SupportConceptList);
|
|
var list = new List<ValueListEntryType>
|
|
{
|
|
ValueListEntryType.SupportConceptGoalCategoryType,
|
|
ValueListEntryType.SupportConceptGoalType,
|
|
ValueListEntryType.SupportConceptIndividualGoalType,
|
|
ValueListEntryType.SupportConceptIndividualGoalCategoryType
|
|
};
|
|
pDataContract.Goals = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDCs(pEntity.ValueList.FindByTypes(list).Select(e2o => e2o.Entry));
|
|
|
|
pDataContract.ServiceAccountings = MapperFactory.ServiceAccountingDC_ServiceAccounting.MapToNewDCs(pEntity.ServiceAccountings);
|
|
|
|
pDataContract.Ratings = MapperFactory.RatingDC_Rating.MapToNewDCs(pEntity.Ratings);
|
|
|
|
IList<VarFieldDef> defs = DAOFactory.SearchDAO.GetVarFieldDefs(TableID.SupportConcept);
|
|
pDataContract.VarFields = MapperFactory.VarFieldDC_VarField.VarFieldMapToDCs(defs, pEntity.VarFieldValueList);
|
|
|
|
return pDataContract;
|
|
}
|
|
|
|
public override SupportConcept MergeWithEntity(SupportConceptDC pDataContract, SupportConcept pEntity)
|
|
{
|
|
this.ConcurrencyCheck(pDataContract.SupportConceptVersion, pEntity);
|
|
|
|
pEntity.Oid = pDataContract.SupportConceptOid;
|
|
pEntity.Conference = pDataContract.Conference;
|
|
pEntity.ConferenceDate = pDataContract.ConferenceDate;
|
|
pEntity.ApprovalDate = pDataContract.ApprovalDate;
|
|
pEntity.RenewalSendDate = pDataContract.RenewalSendDate;
|
|
pEntity.ConsultingNeeded = pDataContract.ConsultingNeeded;
|
|
pEntity.RequisitionSendDate = pDataContract.RequisitionSendDate;
|
|
pEntity.SupportConceptSendDate = pDataContract.SupportConceptSendDate;
|
|
pEntity.ConferenceVenue = pDataContract.ConferenceVenue;
|
|
|
|
if (pEntity.Customer == null || pEntity.Customer.Oid.Value != pDataContract.Customer.CustomerOid)
|
|
{
|
|
pEntity.Customer = DAOFactory.GenericDAO.LoadByID<Customer>(pDataContract.Customer.CustomerOid);
|
|
}
|
|
|
|
// Checkout & Checkin & Fileupload über extra Service...
|
|
pEntity.IsActive = pDataContract.ActivationType;
|
|
if (pDataContract.Originator != null)
|
|
{
|
|
pEntity.Originator = MapperFactory.CompactEmployeeDC_Employee.MergeWithEntity(pDataContract.Originator, pEntity.Originator);
|
|
}
|
|
|
|
pEntity.Notice = pDataContract.Notice;
|
|
|
|
MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MergeWithEntitys(pDataContract.CostBearerRelations, pEntity.CostBearer2SupportConceptList);
|
|
|
|
MapperFactory.RatingDC_Rating.MergeWithEntitys(pDataContract.Ratings, pEntity.Ratings);
|
|
|
|
var globalGoalCategories = new List<ValueListEntryDC>();
|
|
var globalGoals = new List<ValueListEntryDC>();
|
|
var individualGoals = new List<ValueListEntryDC>();
|
|
var individualGoalCategories = new List<ValueListEntryDC>();
|
|
|
|
if (pDataContract.Goals != null)
|
|
{
|
|
globalGoalCategories = pDataContract.Goals.Where(g => g.Type == ValueListEntryType.SupportConceptGoalCategoryType).ToList();
|
|
globalGoals = pDataContract.Goals.Where(g => g.Type == ValueListEntryType.SupportConceptGoalType).ToList();
|
|
individualGoals = pDataContract.Goals.Where(g => g.Type == ValueListEntryType.SupportConceptIndividualGoalType).ToList();
|
|
individualGoalCategories = pDataContract.Goals.Where(g => g.Type == ValueListEntryType.SupportConceptIndividualGoalCategoryType).ToList();
|
|
}
|
|
|
|
MapperFactory.ValueListEntryDC_ValueListEntry.MapValueEntryListBack2Entity(globalGoalCategories, pEntity.ValueList, ValueListEntryType.SupportConceptGoalCategoryType, TableID.SupportConcept, false);
|
|
MapperFactory.ValueListEntryDC_ValueListEntry.MapValueEntryListBack2Entity(globalGoals, pEntity.ValueList, ValueListEntryType.SupportConceptGoalType, TableID.SupportConcept, false);
|
|
MapperFactory.ValueListEntryDC_ValueListEntry.MapValueEntryListBack2Entity(individualGoals, pEntity.ValueList, ValueListEntryType.SupportConceptIndividualGoalType, TableID.SupportConcept, true);
|
|
MapperFactory.ValueListEntryDC_ValueListEntry.MapValueEntryListBack2Entity(individualGoalCategories, pEntity.ValueList, ValueListEntryType.SupportConceptIndividualGoalCategoryType, TableID.SupportConcept, true);
|
|
|
|
MapperFactory.ServiceAccountingDC_ServiceAccounting.MergeWithEntitys(pDataContract.ServiceAccountings, pEntity.ServiceAccountings);
|
|
|
|
pEntity.VarFieldValueList = MapperFactory.VarFieldDC_VarField.VarFieldMergeToEntity(pEntity.VarFieldValueList, pDataContract.VarFields, pEntity);
|
|
|
|
return pEntity;
|
|
}
|
|
|
|
protected override bool AreDCAndEntityEqual(SupportConceptDC pDC, SupportConcept pEntity)
|
|
{
|
|
if (pDC.SupportConceptOid == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return pDC.SupportConceptOid == pEntity.Oid;
|
|
}
|
|
}
|
|
} |