|
|
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.ComponentModel;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
-using System.Globalization;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
@@ -17,10 +16,6 @@ using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
|
using InABox.Wpf;
|
|
|
using InABox.WPF;
|
|
|
-using Org.BouncyCastle.Asn1.X509.Qualified;
|
|
|
-using PRS.Shared;
|
|
|
-using Syncfusion.SfSkinManager;
|
|
|
-using Syncfusion.UI.Xaml.Scheduler;
|
|
|
using Selection = InABox.Core.Selection;
|
|
|
using SelectionChangedEventArgs = System.Windows.Controls.SelectionChangedEventArgs;
|
|
|
|
|
|
@@ -602,6 +597,8 @@ namespace PRSDesktop
|
|
|
|
|
|
// Populated on each Refresh
|
|
|
private List<Assignment> _assignments = [];
|
|
|
+
|
|
|
+ private ObservableCollection<ICalendarAppointment> _appointments = new();
|
|
|
|
|
|
private bool bColumnsLoaded;
|
|
|
|
|
|
@@ -776,15 +773,15 @@ namespace PRSDesktop
|
|
|
|
|
|
LoadBackground();
|
|
|
|
|
|
- var appointments = new List<ICalendarAppointment>();
|
|
|
- LoadStandardLeaves(appointments);
|
|
|
- LoadLeaveRequests(appointments);
|
|
|
- LoadAssignments(appointments);
|
|
|
+ _appointments.Clear();
|
|
|
+ LoadStandardLeaves(_appointments);
|
|
|
+ LoadLeaveRequests(_appointments);
|
|
|
+ LoadAssignments(_appointments);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
CalendarControl.Dates = CoreUtils.Range(startDate, endDate, x => x.AddDays(1));
|
|
|
- CalendarControl.ItemsSource = appointments;
|
|
|
+ CalendarControl.ItemsSource = _appointments;
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
@@ -932,7 +929,7 @@ namespace PRSDesktop
|
|
|
CalendarControl.Regions = regions;
|
|
|
}
|
|
|
|
|
|
- private void LoadStandardLeaves(List<ICalendarAppointment> appointments)
|
|
|
+ private void LoadStandardLeaves(IList<ICalendarAppointment> appointments)
|
|
|
{
|
|
|
for (var date = StartDate; date < EndDate; date = date.AddDays(1))
|
|
|
{
|
|
|
@@ -962,7 +959,7 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void LoadLeaveRequests(List<ICalendarAppointment> appointments)
|
|
|
+ private void LoadLeaveRequests(IList<ICalendarAppointment> appointments)
|
|
|
{
|
|
|
for (var date = StartDate; date < EndDate; date = date.AddDays(1))
|
|
|
{
|
|
|
@@ -985,13 +982,16 @@ namespace PRSDesktop
|
|
|
var start = (date.Date == leave.From.Date) ? leave.FromTime : TimeSpan.FromSeconds(0);
|
|
|
var finish = (date.Date == leave.To.Date) ? leave.ToTime : TimeSpan.FromDays(1).Subtract(TimeSpan.FromSeconds(1));
|
|
|
var blocks = roster.GetBlocks(date, start, finish);
|
|
|
- appointments.AddRange(blocks.Select(x => new LeaveRequestAppointment(leave, employee, x)));
|
|
|
+ foreach(var block in blocks)
|
|
|
+ {
|
|
|
+ appointments.Add(new LeaveRequestAppointment(leave, employee, block));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void LoadAssignment(Assignment assignment, List<ICalendarAppointment> appointments)
|
|
|
+ private void LoadAssignment(Assignment assignment, IList<ICalendarAppointment> appointments)
|
|
|
{
|
|
|
var employee = _employees.FirstOrDefault(x => x.ID == assignment.EmployeeLink.ID);
|
|
|
if (employee is null) return;
|
|
|
@@ -1004,7 +1004,7 @@ namespace PRSDesktop
|
|
|
appointments.Add(model);
|
|
|
}
|
|
|
|
|
|
- private void LoadAssignments(List<ICalendarAppointment> appointments)
|
|
|
+ private void LoadAssignments(IList<ICalendarAppointment> appointments)
|
|
|
{
|
|
|
foreach (var assignment in _assignments)
|
|
|
LoadAssignment(assignment, appointments);
|
|
|
@@ -1212,7 +1212,8 @@ namespace PRSDesktop
|
|
|
|
|
|
if ((args.Status == CalendarHandledStatus.Handled) || CheckGrid(ref ag).EditItems([ass]))
|
|
|
{
|
|
|
- // TODO: UpdateAssignment(ass);
|
|
|
+ _assignments.Add(ass);
|
|
|
+ LoadAssignment(ass, _appointments);
|
|
|
_copiedmodel = null;
|
|
|
}
|
|
|
|