Files
BeWoPlaner/BeWo/Scheduler/Utils/AppointmentExtensions.cs

231 lines
8.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using BeWo.Scheduler.ViewModel;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using DevExpress.XtraScheduler;
namespace BeWo.Scheduler.Utils
{
public static class AppointmentExtensions
{
#region CustomField Getters
public static CustomFieldStorage GetCustomFieldStorage(this Appointment appointment)
{
try
{
return appointment.CustomFields[nameof(CustomFieldStorage)] as CustomFieldStorage;
}
catch (Exception)
{
}
return new CustomFieldStorage();
}
public static bool CF_IsTask(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.IsTask ?? false;
}
public static bool CF_IsAbsenceTime(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.IsAbsenceTime ?? false;
}
public static bool CF_IsPrivate(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.IsPrivate ?? false;
}
public static bool CF_IsAllDay(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.IsAllDay ?? false;
}
public static ObservableCollection<Employee2SchedulerAppointmentDC> CF_EmployeeList(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.EmployeeList ?? new ObservableCollection<Employee2SchedulerAppointmentDC>();
}
public static List<CompactCustomerDC> CF_CustomerList(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.CustomerList ?? new List<CompactCustomerDC>();
}
public static List<ResourceDC> CF_ResourceList(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.ResourceList ?? new List<ResourceDC>();
}
public static List<CompactSupportConceptDC> CF_SupportConceptList(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.SupportConceptList ?? new List<CompactSupportConceptDC>();
}
public static DateTime? CF_DueDate(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.DueDate;
}
public static DateTime? CF_CompletedDate(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.CompletedDate;
}
public static string CF_CompletedNotice(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.CompletedNotice;
}
public static string CF_TaskDescription(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.TaskDescription;
}
public static CompactEmployeeDC CF_Originator(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.Originator;
}
public static long? CF_SchedulerAppointmentOid(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.SchedulerAppointmentOid;
}
public static bool CF_HasServiceRecordEntry(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.HasServiceRecordEntry ?? false;
}
public static bool CF_CanBeEdited(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.CanBeEdited ?? false;
}
public static long? CF_AbsenceTimeOid(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.AbsenceTimeOid;
}
public static bool CF_IsCustomerAbsenceTime(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.IsCustomerAbsenceTime ?? false;
}
public static List<ServiceRecordDC> CF_ServiceRecordList(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.ServiceRecordList ?? new List<ServiceRecordDC>();
}
public static string CF_CompletedUser(this Appointment appointment)
{
return appointment.GetCustomFieldStorage()?.CompletedUser;
}
#endregion
#region CustomField Setters
public static void CF_IsTask(this Appointment appointment, bool pIsTask)
{
appointment.GetCustomFieldStorage().IsTask = pIsTask;
}
public static void CF_IsAbsenceTime(this Appointment appointment, bool pIsAbsenceTime)
{
appointment.GetCustomFieldStorage().IsAbsenceTime = pIsAbsenceTime;
}
public static void CF_IsPrivate(this Appointment appointment, bool pIsPrivate)
{
appointment.GetCustomFieldStorage().IsPrivate = pIsPrivate;
}
public static void CF_IsAllDay(this Appointment appointment, bool pIsAllDay)
{
appointment.GetCustomFieldStorage().IsAllDay = pIsAllDay;
}
public static void CF_AbsenceTimeOid(this Appointment appointment, long? absenceTimeOid)
{
appointment.GetCustomFieldStorage().AbsenceTimeOid = absenceTimeOid;
}
public static void CF_IsCustomerAbsenceTime(this Appointment appointment, bool isCustomerAbsenceTime)
{
appointment.GetCustomFieldStorage().IsCustomerAbsenceTime = isCustomerAbsenceTime;
}
public static void CF_EmployeeList(this Appointment appointment, ObservableCollection<Employee2SchedulerAppointmentDC> pEmployeeList)
{
appointment.GetCustomFieldStorage().EmployeeList = pEmployeeList;
}
public static void CF_ResourceList(this Appointment appointment, List<ResourceDC> pResourceList)
{
appointment.GetCustomFieldStorage().ResourceList = pResourceList;
}
public static void CF_CustomerList(this Appointment appointment, List<CompactCustomerDC> pCustomerList)
{
appointment.GetCustomFieldStorage().CustomerList = pCustomerList;
}
public static void CF_SupportConceptList(this Appointment appointment, List<CompactSupportConceptDC> pSupportConceptList)
{
appointment.GetCustomFieldStorage().SupportConceptList = pSupportConceptList;
}
public static void CF_Originator(this Appointment appointment, CompactEmployeeDC pOriginator)
{
appointment.GetCustomFieldStorage().Originator = pOriginator;
}
public static void CF_DueDate(this Appointment appointment, DateTime? pDueDate)
{
appointment.GetCustomFieldStorage().DueDate = pDueDate;
}
public static void CF_CompletedDate(this Appointment appointment, DateTime? pCompletedDate)
{
appointment.GetCustomFieldStorage().CompletedDate = pCompletedDate;
}
public static void CF_CompletedNotice(this Appointment appointment, string pCompletedNotice)
{
appointment.GetCustomFieldStorage().CompletedNotice = pCompletedNotice;
}
public static void CF_TaskDescription(this Appointment appointment, string pTaskDescription)
{
appointment.GetCustomFieldStorage().TaskDescription = pTaskDescription;
}
public static void CF_HasServiceRecordEntry(this Appointment appointment, bool hasServiceRecordEntry)
{
appointment.GetCustomFieldStorage().HasServiceRecordEntry = hasServiceRecordEntry;
}
public static void CF_ServiceRecordList(this Appointment appointment, List<ServiceRecordDC> serviceRecords)
{
appointment.GetCustomFieldStorage().ServiceRecordList = serviceRecords;
}
public static void CF_CompletedUser(this Appointment appointment, string completedUser)
{
appointment.GetCustomFieldStorage().CompletedUser = completedUser;
}
#endregion
}
}