128 lines
6.3 KiB
C#
128 lines
6.3 KiB
C#
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
|
|
using BS.Shared.DataContracts;
|
|
|
|
namespace BeWo.Service.DCEntityMapper
|
|
{
|
|
public class ContractDC_Contract : AbstractIDCEntityMapper<Contract, ContractDC>
|
|
{
|
|
public override ContractDC MergeWithDC(Contract pEntity, ContractDC pDataContract)
|
|
{
|
|
pDataContract.ContractOid = pEntity.Oid;
|
|
pDataContract.ContractVersion = pEntity.Version;
|
|
pDataContract.CancellationPeriod = pEntity.CancellationPeriod;
|
|
pDataContract.ContractEndDate = pEntity.ContractEndDate;
|
|
pDataContract.EntryDate = pEntity.EntryDate;
|
|
pDataContract.HourlyRate = pEntity.HourlyRate;
|
|
pDataContract.GrossSalary = pEntity.GrossSalary;
|
|
pDataContract.LeaveDays = pEntity.LeaveDays;
|
|
pDataContract.ProbationPeriod = pEntity.ProbationPeriod;
|
|
pDataContract.ProbationPeriod2 = pEntity.ProbationPeriod2;
|
|
pDataContract.WeeklyDays = pEntity.WeeklyDays ?? 5;
|
|
if (pDataContract.WeeklyDays == 0)
|
|
pDataContract.WeeklyDays = 5;
|
|
pDataContract.WeeklyFLS = pEntity.WeeklyFLS;
|
|
pDataContract.MonthlyFLS = pEntity.MonthlyFLS;
|
|
pDataContract.WeeklyTotalHours = pEntity.WeeklyTotalHours;
|
|
pDataContract.MonthlyTotalHours = pEntity.MonthlyTotalHours;
|
|
pDataContract.Notice = pEntity.Notice;
|
|
|
|
if (pEntity.EmploymentType != null)
|
|
{
|
|
pDataContract.EmploymentType = MapperFactory.EmploymentTypeDC_EmploymentType.MapToNewDC(pEntity.EmploymentType);
|
|
}
|
|
if (pEntity.ContractTypeValueListEntry != null)
|
|
{
|
|
pDataContract.ContractTypeValueListEntry = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDC(pEntity.ContractTypeValueListEntry);
|
|
}
|
|
if (pEntity.QualifikationsBedarfValueListEntry != null)
|
|
{
|
|
pDataContract.QualifikationsBedarfValueListEntry = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDC(pEntity.QualifikationsBedarfValueListEntry);
|
|
}
|
|
if (pEntity.HourlyRateCostRateValue != null)
|
|
{
|
|
pDataContract.HourlyRateCostRateValue = MapperFactory.CostRatePeriodDC_CostRatePeriod.MapToNewDC(pEntity.HourlyRateCostRateValue);
|
|
}
|
|
return pDataContract;
|
|
}
|
|
|
|
public override Contract MergeWithEntity(ContractDC pDataContract, Contract pEntity)
|
|
{
|
|
this.ConcurrencyCheck(pDataContract.ContractVersion, pEntity);
|
|
|
|
pEntity.CancellationPeriod = pDataContract.CancellationPeriod;
|
|
pEntity.ContractEndDate = pDataContract.ContractEndDate;
|
|
if (pEntity.ContractEndDate.HasValue)
|
|
{
|
|
pEntity.ContractEndDate = pEntity.ContractEndDate.Value.Date; // CB Bugfix, es gab mal den Fall, da war die Uhrzeit mit gespeichert und das führte zu Fehlern
|
|
}
|
|
pEntity.EntryDate = pDataContract.EntryDate;
|
|
if (pEntity.EntryDate.HasValue)
|
|
{
|
|
pEntity.EntryDate = pEntity.EntryDate.Value.Date; // CB Bugfix, es gab mal den Fall, da war die Uhrzeit mit gespeichert und das führte zu Fehlern
|
|
}
|
|
pEntity.HourlyRate = pDataContract.HourlyRate;
|
|
pEntity.GrossSalary = pDataContract.GrossSalary;
|
|
pEntity.LeaveDays = pDataContract.LeaveDays;
|
|
pEntity.ProbationPeriod = pDataContract.ProbationPeriod;
|
|
pEntity.ProbationPeriod2 = pDataContract.ProbationPeriod2;
|
|
pEntity.WeeklyDays = pDataContract.WeeklyDays;
|
|
pEntity.WeeklyFLS = pDataContract.WeeklyFLS;
|
|
pEntity.MonthlyFLS = pDataContract.MonthlyFLS;
|
|
pEntity.WeeklyTotalHours = pDataContract.WeeklyTotalHours;
|
|
pEntity.MonthlyTotalHours = pDataContract.MonthlyTotalHours;
|
|
pEntity.Notice = pDataContract.Notice;
|
|
|
|
pEntity.Oid = pDataContract.ContractOid;
|
|
|
|
if (pDataContract.EmploymentType == null)
|
|
{
|
|
pEntity.EmploymentType = null;
|
|
}
|
|
else if (pEntity.EmploymentType == null || pEntity.EmploymentType.Oid != pDataContract.EmploymentType.EmploymentTypeOid)
|
|
{
|
|
pEntity.EmploymentType = DAOFactory.GenericDAO.LoadByID<EmploymentType>(pDataContract.EmploymentType.EmploymentTypeOid.Value);
|
|
}
|
|
|
|
|
|
if (pDataContract.ContractTypeValueListEntry == null)
|
|
{
|
|
pEntity.ContractTypeValueListEntry = null;
|
|
}
|
|
else if (pEntity.ContractTypeValueListEntry == null || pEntity.ContractTypeValueListEntry.Oid != pDataContract.ContractTypeValueListEntry.ValueListEntryOid)
|
|
{
|
|
pEntity.ContractTypeValueListEntry = DAOFactory.GenericDAO.LoadByID<ValueListEntry>(pDataContract.ContractTypeValueListEntry.ValueListEntryOid.Value);
|
|
}
|
|
|
|
if (pDataContract.QualifikationsBedarfValueListEntry == null)
|
|
{
|
|
pEntity.QualifikationsBedarfValueListEntry = null;
|
|
}
|
|
else if (pEntity.QualifikationsBedarfValueListEntry == null || pEntity.QualifikationsBedarfValueListEntry.Oid != pDataContract.QualifikationsBedarfValueListEntry.ValueListEntryOid)
|
|
{
|
|
pEntity.QualifikationsBedarfValueListEntry = DAOFactory.GenericDAO.LoadByID<ValueListEntry>(pDataContract.QualifikationsBedarfValueListEntry.ValueListEntryOid.Value);
|
|
}
|
|
|
|
if (pDataContract.HourlyRateCostRateValue == null)
|
|
{
|
|
pEntity.HourlyRateCostRateValue = null;
|
|
}
|
|
else if (pEntity.HourlyRateCostRateValue == null || pEntity.HourlyRateCostRateValue.Oid != pDataContract.HourlyRateCostRateValue.CostRatePeriodOid)
|
|
{
|
|
pEntity.HourlyRateCostRateValue = DAOFactory.GenericDAO.LoadByID<CostRatePeriod>(pDataContract.HourlyRateCostRateValue.CostRatePeriodOid.Value);
|
|
}
|
|
return pEntity;
|
|
}
|
|
|
|
protected override bool AreDCAndEntityEqual(ContractDC pDC, Contract pEntity)
|
|
{
|
|
if (pDC.ContractOid == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return pDC.ContractOid == pEntity.Oid;
|
|
}
|
|
}
|
|
} |