121 lines
4.8 KiB
C#
121 lines
4.8 KiB
C#
using System;
|
|
using System.Linq;
|
|
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
|
|
using BS.Shared.DataContracts;
|
|
|
|
using DevExpress.XtraCharts.Native;
|
|
|
|
namespace BeWo.Service.DCEntityMapper
|
|
{
|
|
public class SchedulerAppointmentDC_SchedulerAppointment : AbstractIDCEntityMapper<SchedulerAppointment, SchedulerAppointmentDC>
|
|
{
|
|
public override SchedulerAppointmentDC MergeWithDC(SchedulerAppointment pEntity, SchedulerAppointmentDC pDataContract)
|
|
{
|
|
pDataContract.SchedulerAppointmentOid = pEntity.Oid;
|
|
pDataContract.NewSchedulerAppointmentVersion = pEntity.Version;
|
|
|
|
pDataContract.AllDay = pEntity.AllDay;
|
|
pDataContract.EndDate = pEntity.EndDate;
|
|
pDataContract.StartDate = pEntity.StartDate;
|
|
pDataContract.Status = pEntity.Status;
|
|
pDataContract.Subject = pEntity.Subject;
|
|
pDataContract.Type = pEntity.Type;
|
|
pDataContract.Location = pEntity.Location;
|
|
pDataContract.Description = pEntity.Notice;
|
|
pDataContract.RecurrenceInfo = pEntity.RecurrenceInfo;
|
|
pDataContract.ReminderInfo = pEntity.ReminderInfo;
|
|
|
|
pDataContract.IsPrivate = pEntity.IsPrivate;
|
|
pDataContract.CustomerList = MapperFactory.CompactCustomerDC_Customer.MapToNewDCs(pEntity.CustomerList);
|
|
pDataContract.ResourceList = MapperFactory.ResourceDC_Resource.MapToNewDCs(pEntity.ResourceList);
|
|
pDataContract.EmployeeList = MapperFactory.Employee2SchedulerAppointmentDC_Employee2SchedulerAppointment.MapToNewDCs(pEntity.EmployeeList);
|
|
|
|
pDataContract.IsTask = pEntity.IsTask;
|
|
pDataContract.TaskDescription = pEntity.TaskDescription;
|
|
pDataContract.CompletedNotice = pEntity.CompletedNotice;
|
|
pDataContract.CompletedDate = pEntity.CompletedDate;
|
|
|
|
pDataContract.DueDate = pEntity.DueDate;
|
|
|
|
pDataContract.FormerBookingSequenceOid = pEntity.FormerBookingSequenceOid;
|
|
pDataContract.SupportConceptList = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDCs(pEntity.SupportConceptList);
|
|
|
|
pDataContract.FormerTaskOid = pEntity.FormerTaskOid;
|
|
|
|
pDataContract.HasServiceRecordEntry = pEntity.HasServiceRecordEntry;
|
|
|
|
if (pEntity.Originator != null)
|
|
{
|
|
pDataContract.Originator = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Originator);
|
|
}
|
|
|
|
return pDataContract;
|
|
}
|
|
|
|
public override SchedulerAppointment MergeWithEntity(SchedulerAppointmentDC pDataContract, SchedulerAppointment pEntity)
|
|
{
|
|
ConcurrencyCheck(pDataContract.NewSchedulerAppointmentVersion, pEntity);
|
|
|
|
pEntity.Oid = pDataContract.SchedulerAppointmentOid;
|
|
pEntity.Version = pDataContract.NewSchedulerAppointmentVersion;
|
|
|
|
pEntity.AllDay = pDataContract.AllDay;
|
|
pEntity.EndDate = pDataContract.EndDate;
|
|
pEntity.StartDate = pDataContract.StartDate;
|
|
pEntity.Status = pDataContract.Status;
|
|
pEntity.Subject = pDataContract.Subject;
|
|
pEntity.Type = pDataContract.Type;
|
|
pEntity.Location = pDataContract.Location;
|
|
pEntity.Notice = pDataContract.Description;
|
|
pEntity.RecurrenceInfo = pDataContract.RecurrenceInfo;
|
|
pEntity.ReminderInfo = pDataContract.ReminderInfo;
|
|
|
|
pEntity.FormerBookingSequenceOid = pDataContract.FormerBookingSequenceOid;
|
|
|
|
pEntity.IsTask = pDataContract.IsTask;
|
|
pEntity.TaskDescription = pDataContract.TaskDescription;
|
|
pEntity.CompletedNotice = pDataContract.CompletedNotice;
|
|
pEntity.CompletedDate = pDataContract.CompletedDate;
|
|
pEntity.DueDate = pDataContract.DueDate;
|
|
|
|
pEntity.FormerTaskOid = pDataContract.FormerTaskOid;
|
|
|
|
if (pDataContract.Originator != null)
|
|
{
|
|
pEntity.Originator = MapperFactory.CompactEmployeeDC_Employee.MapToNewEntity(pDataContract.Originator);
|
|
}
|
|
|
|
pEntity.IsPrivate = pDataContract.IsPrivate;
|
|
|
|
pEntity.HasServiceRecordEntry = pDataContract.HasServiceRecordEntry;
|
|
|
|
try
|
|
{
|
|
pEntity.EmployeeList = DAOFactory.GenericDAO.LoadByIDs<Employee2SchedulerAppointment>(pDataContract.EmployeeList.Select(e => e.Employee2SchedulerAppointmentOid.Value));
|
|
pEntity.CustomerList = DAOFactory.GenericDAO.LoadByIDs<Customer>(pDataContract.CustomerList.Select(c => c.CustomerOid));
|
|
pEntity.ResourceList = DAOFactory.GenericDAO.LoadByIDs<Resource>(pDataContract.ResourceList.Select(r => r.ResourceOid.Value));
|
|
pEntity.SupportConceptList = DAOFactory.GenericDAO.LoadByIDs<SupportConcept>(pDataContract.SupportConceptList.Select(s => s.SupportConceptOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new InternalException(e.Message);
|
|
}
|
|
|
|
return pEntity;
|
|
}
|
|
|
|
protected override bool AreDCAndEntityEqual(SchedulerAppointmentDC pDC, SchedulerAppointment pEntity)
|
|
{
|
|
if (pDC.SchedulerAppointmentOid == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return pDC.SchedulerAppointmentOid == pEntity.Oid;
|
|
}
|
|
}
|
|
}
|