using BS.Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; using BS.Shared.DataContracts.Compact; namespace BeWoPlanerMobil.Models { [Serializable] public class AppointmentModel : AbstractModel { public AppointmentSessionModel AppointmentSessionModel => SessionModel as AppointmentSessionModel; public long? Oid { get; set; } public int? EventType { get; set; } public int? Label { get; set; } public bool AllDay { get; set; } public string Location { get; set; } public int? Status { get; set; } public string RecurrenceInfo { get; set; } public string Subject { get; set; } public DateTime? StartTime { get; set; } public DateTime? EndTime { get; set; } public string Description { get; set; } public bool IsPrivate { get; set; } public bool CanBeEdited { get; set; } public bool IsTask { get; set; } public DateTime? DueDate { get; set; } public DateTime? CompletedDate { get; set; } public string CompletedNotice { get; set; } public string CompletedUser { get; set; } public string TaskDescription { get; set; } public List SelectedCustomers { get { return SelectedCustomerOids is null ? null : PossibleCustomers.Where(customer => SelectedCustomerOids.Contains(customer.CustomerOid)).ToList(); } set { SelectedCustomerOids = value?.Select(customer => customer.CustomerOid).ToList(); } } public List SelectedResources { get { return SelectedResourceOids is null ? null : PossibleResources.Where(resource => resource.ResourceOid.HasValue && SelectedResourceOids.Contains(resource.ResourceOid.Value)).ToList(); } set { SelectedResourceOids = value?.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); } } public bool HasServiceRecordEntry { get; set; } public List ServiceRecordList { get; set; } public List PossibleCustomers { get; set; } public List PossibleResources { get; set; } public List SelectedCustomerOids { get => AppointmentSessionModel.SelectedCustomerOids; set => AppointmentSessionModel.SelectedCustomerOids = value; } public List SelectedResourceOids { get => AppointmentSessionModel.SelectedResourceOids; set => AppointmentSessionModel.SelectedResourceOids = value; } /* Mitarbeiter */ public List PossibleEmployees { get; set; } public List SelectedEmployee2SchedulerAppointments { get; set; } public List SelectedEmployees { get; set; } public List SelectedEmployeeOids { get => AppointmentSessionModel.SelectedEmployeeOids; set => AppointmentSessionModel.SelectedEmployeeOids = value; } public List SelectedEmployees2Appointments { get => AppointmentSessionModel.SelectedEmployees2Appointments; set => AppointmentSessionModel.SelectedEmployees2Appointments = value; } /* /Mitarbeiter */ public AppointmentModel() { SessionModel = new AppointmentSessionModel(); } public AppointmentModel(List possibleCustomers, List possibleResources, List possibleEmployees) { PossibleCustomers = possibleCustomers; PossibleResources = possibleResources; PossibleEmployees = possibleEmployees; SessionModel = new AppointmentSessionModel(); } public AppointmentModel(SchedulerAppointmentDC appointment) { if(appointment is null) { return; } SessionModel = new AppointmentSessionModel(); Oid = appointment.SchedulerAppointmentOid; EventType = appointment.Type; AllDay = appointment.AllDay; Location = appointment.Location; Status = appointment.Status; RecurrenceInfo = appointment.RecurrenceInfo; Subject = appointment.Subject; StartTime = appointment.StartDate; EndTime = appointment.EndDate; Description = appointment.Description; SelectedCustomers = appointment.CustomerList; SelectedEmployees = appointment.EmployeeList?.Select(employee2Appointment => employee2Appointment.Employee)?.ToList(); SelectedEmployee2SchedulerAppointments = appointment.EmployeeList; SelectedResources = appointment.ResourceList; HasServiceRecordEntry = appointment.HasServiceRecordEntry; ServiceRecordList = appointment.ServiceRecordList; CanBeEdited = appointment.CanBeEdited; IsPrivate = appointment.IsPrivate; IsTask = appointment.IsTask; DueDate = appointment.DueDate; CompletedDate = appointment.CompletedDate; CompletedNotice = appointment.CompletedNotice; CompletedUser = appointment.CompletedUser; TaskDescription = appointment.TaskDescription; } public virtual void Assign(AppointmentModel source) { if(source is null) { return; } Oid = source.Oid; EventType = source.EventType; Label = source.Label; AllDay = source.AllDay; Location = source.Location; Status = source.Status; RecurrenceInfo = source.RecurrenceInfo; Subject = source.Subject; StartTime = source.StartTime; EndTime = source.EndTime; Description = source.Description; SelectedCustomers = source.SelectedCustomers; SelectedEmployees = source.SelectedEmployees; SelectedEmployee2SchedulerAppointments = source.SelectedEmployee2SchedulerAppointments; SelectedResources = source.SelectedResources; HasServiceRecordEntry = source.HasServiceRecordEntry; ServiceRecordList = source.ServiceRecordList; CanBeEdited = source.CanBeEdited; IsPrivate = source.IsPrivate; IsTask = source.IsTask; DueDate = source.DueDate; CompletedDate = source.CompletedDate; CompletedNotice = source.CompletedNotice; CompletedUser = source.CompletedUser; TaskDescription = source.TaskDescription; } } }