소스 검색

Initial changes

Kenric Nugteren 7 달 전
부모
커밋
fa33a8d6d0
1개의 변경된 파일456개의 추가작업 그리고 280개의 파일을 삭제
  1. 456 280
      prs.desktop/Dashboards/Equipment/EquipmentSchedulesDashboard.xaml.cs

+ 456 - 280
prs.desktop/Dashboards/Equipment/EquipmentSchedulesDashboard.xaml.cs

@@ -21,372 +21,548 @@ using System.Windows.Media.Imaging;
 using InABox.Configuration;
 using Client = InABox.Clients.Client;
 
-namespace PRSDesktop.Dashboards
+namespace PRSDesktop.Dashboards;
+
+public class EquipmentSchedulesDashboardProperties : IUserConfigurationSettings, IDashboardProperties
 {
-    public class EquipmentSchedulesDashboardProperties : IUserConfigurationSettings, IDashboardProperties
-    {
 
-    }
+}
 
-    public class ScheduleViewModel : INotifyPropertyChanged
-    {
-        private Guid employeeID;
-        private string? employeeName;
-        private string? employeeMobile;
-        private string? employeeEmail;
-        private BitmapImage? employeeImage;
+public class ScheduleViewModel : INotifyPropertyChanged
+{
+    private Guid employeeID;
+    private string? employeeName;
+    private string? employeeMobile;
+    private string? employeeEmail;
+    private BitmapImage? employeeImage;
 
-        public bool HasEmployee => EmployeeID != Guid.Empty;
+    public bool HasEmployee => EmployeeID != Guid.Empty;
 
-        public Guid ID { get; set; }
+    public Guid ID { get; set; }
 
-        public string Title { get; set; }
+    public string Title { get; set; }
 
-        public DateTime DueDate { get; set; }
+    public DateTime DueDate { get; set; }
 
-        public BitmapImage? EmployeeImage
+    public BitmapImage? EmployeeImage
+    {
+        get => employeeImage;
+        set
         {
-            get => employeeImage;
-            set
-            {
-                employeeImage = value;
-                NotifyPropertyChanged();
-            }
+            employeeImage = value;
+            NotifyPropertyChanged();
         }
+    }
 
-        public Guid EmployeeID
+    public Guid EmployeeID
+    {
+        get => employeeID;
+        set
         {
-            get => employeeID;
-            set
-            {
-                employeeID = value;
-                NotifyPropertyChanged(nameof(HasEmployee));
-            }
+            employeeID = value;
+            NotifyPropertyChanged(nameof(HasEmployee));
         }
+    }
 
-        public string? EmployeeName
+    public string? EmployeeName
+    {
+        get => employeeName;
+        set
         {
-            get => employeeName;
-            set
-            {
-                employeeName = value;
-                NotifyPropertyChanged();
-            }
+            employeeName = value;
+            NotifyPropertyChanged();
         }
+    }
 
-        public string? EmployeeMobile
+    public string? EmployeeMobile
+    {
+        get => employeeMobile;
+        set
         {
-            get => employeeMobile;
-            set
-            {
-                employeeMobile = value;
-                NotifyPropertyChanged();
-                NotifyPropertyChanged(nameof(EmployeeContact));
-            }
+            employeeMobile = value;
+            NotifyPropertyChanged();
+            NotifyPropertyChanged(nameof(EmployeeContact));
         }
+    }
 
-        public string? EmployeeEmail
+    public string? EmployeeEmail
+    {
+        get => employeeEmail;
+        set
         {
-            get => employeeEmail;
-            set
-            {
-                employeeEmail = value;
-                NotifyPropertyChanged();
-                NotifyPropertyChanged(nameof(EmployeeContact));
-            }
+            employeeEmail = value;
+            NotifyPropertyChanged();
+            NotifyPropertyChanged(nameof(EmployeeContact));
         }
+    }
 
-        public string? EmployeeContact
+    public string? EmployeeContact
+    {
+        get
         {
-            get
+            var str = "";
+            if (EmployeeEmail is not null) str = EmployeeEmail;
+            if(EmployeeMobile is not null)
             {
-                var str = "";
-                if (EmployeeEmail is not null) str = EmployeeEmail;
-                if(EmployeeMobile is not null)
+                if (string.IsNullOrWhiteSpace(str))
                 {
-                    if (string.IsNullOrWhiteSpace(str))
-                    {
-                        str = EmployeeMobile;
-                    }
-                    else
-                    {
-                        str += $", {EmployeeMobile}";
-                    }
+                    str = EmployeeMobile;
+                }
+                else
+                {
+                    str += $", {EmployeeMobile}";
                 }
-
-                return string.IsNullOrWhiteSpace(str) ? null : str;
             }
-        }
 
-        public event PropertyChangedEventHandler? PropertyChanged;
-
-        private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
-        {
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+            return string.IsNullOrWhiteSpace(str) ? null : str;
         }
     }
 
-    public class EquipmentScheduleViewModel
+    public event PropertyChangedEventHandler? PropertyChanged;
+
+    private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
     {
-        public bool HasLocation { get; set; }
+        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+    }
+}
 
-        public Guid ID { get; set; }
+public class EquipmentScheduleViewModel
+{
+    public bool HasLocation { get; set; }
 
-        public string Code { get; set; }
+    public Guid ID { get; set; }
 
-        public string Description { get; set; }
+    public string Code { get; set; }
+
+    public string Description { get; set; }
+
+    public List<ScheduleViewModel> Schedules { get; set; }
+}
 
-        public List<ScheduleViewModel> Schedules { get; set; }
+[ValueConversion(typeof(DateTime), typeof(SolidColorBrush))]
+class ScheduleBackgroundConverter : IValueConverter
+{
+    public Color GetColor(DateTime date)
+    {
+        var diff = date - DateTime.Today;
+        if (diff < TimeSpan.Zero)
+            return Colors.Salmon;
+        else if (diff.TotalDays <= 7)
+            return Colors.Orange;
+        else if (diff.Days <= 30)
+            return Colors.LightYellow;
+        else
+            return Colors.LightGreen;
     }
 
-    [ValueConversion(typeof(DateTime), typeof(SolidColorBrush))]
-    class ScheduleBackgroundConverter : IValueConverter
+    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
     {
-        public Color GetColor(DateTime date)
-        {
-            var diff = date - DateTime.Today;
-            if (diff < TimeSpan.Zero)
-                return Colors.Salmon;
-            else if (diff.TotalDays <= 7)
-                return Colors.Orange;
-            else if (diff.Days <= 30)
-                return Colors.LightYellow;
-            else
-                return Colors.LightGreen;
-        }
+        var date = (DateTime)value;
+        var color = GetColor(date);
+        return new SolidColorBrush(color);
+    }
 
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            var date = (DateTime)value;
-            var color = GetColor(date);
-            return new SolidColorBrush(color);
-        }
+    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+    {
+        throw new NotImplementedException();
+    }
+}
 
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            throw new NotImplementedException();
-        }
+/// <summary>
+/// Interaction logic for EquipmentSchedulesDashboard.xaml
+/// </summary>
+public partial class EquipmentSchedulesDashboard : UserControl, IDashboardWidget<EquipmentDashboardGroup, EquipmentSchedulesDashboardProperties>, IHeaderDashboard
+{
+    public EquipmentSchedulesDashboardProperties Properties { get; set; } = null!;
+
+    public DashboardHeader Header { get; set; } = new();
+
+    public event LoadSettings<EquipmentSchedulesDashboardProperties>? LoadSettings;
+    public event SaveSettings<EquipmentSchedulesDashboardProperties>? SaveSettings;
+
+    private Dictionary<Guid, Equipment> Equipment = new();
+
+    private Dictionary<Guid, BitmapImage?> EmployeeImages = new();
+
+    private Dictionary<Guid, Employee> Employees = new();
+
+    private List<EquipmentScheduleViewModel> Models = new();
+
+    public EquipmentSchedulesDashboard()
+    {
+        InitializeComponent();
     }
 
-    /// <summary>
-    /// Interaction logic for EquipmentSchedulesDashboard.xaml
-    /// </summary>
-    public partial class EquipmentSchedulesDashboard : UserControl, IDashboardWidget<EquipmentDashboardGroup, EquipmentSchedulesDashboardProperties>
+    public void Setup()
     {
-        public EquipmentSchedulesDashboardProperties Properties { get; set; } = null!;
-        public event LoadSettings<EquipmentSchedulesDashboardProperties>? LoadSettings;
-        public event SaveSettings<EquipmentSchedulesDashboardProperties>? SaveSettings;
+        LoadEmployeeImages();
 
-        private Dictionary<Guid, Equipment> Equipment = new();
+        SetupHeader();
+    }
 
-        private Dictionary<Guid, BitmapImage?> EmployeeImages = new();
+    #region Header
 
-        private Dictionary<Guid, Employee> Employees = new();
+    CheckBox ShowAllBox = null!;
 
-        private List<EquipmentScheduleViewModel> Models = new();
+    public void SetupHeader()
+    {
+        ShowAllBox = new CheckBox();
+
+        // CategoryBox = new ComboBox
+        // {
+        //     Width = 150,
+        //     VerticalContentAlignment = VerticalAlignment.Center,
+        //     Margin = new Thickness(0, 0, 5, 0)
+        // };
+        // CategoryBox.ItemsSource = Categories;
+        // CategoryBox.SelectedValuePath = "Item1";
+        // CategoryBox.DisplayMemberPath = "Item3";
+        // CategoryBox.SelectedValue = Properties.Category;
+        // CategoryBox.SelectionChanged += Category_SelectionChanged;
+
+        // CategoryButtonPanel = new StackPanel
+        // {
+        //     Orientation = Orientation.Horizontal,
+        //     Margin = new Thickness(0, 0, 5, 0)
+        // };
+        // 
+        // CategoryButtons.Clear();
+        // foreach(var (appliesTo, category, display) in Categories)
+        // {
+        //     if(category is null)
+        //     {
+        //         continue;
+        //     }
+        //     var button = new Button();
+        //     button.Tag = appliesTo;
+        //     button.Margin = new Thickness(0, 0, 2, 0);
+        //     button.BorderBrush = new SolidColorBrush(Colors.Gray);
+        //     button.BorderThickness = new Thickness(0.75);
+        //     button.Width = 25D;
+        //     button.Padding = new Thickness(2);
+        //     button.ToolTip = category.EntityName().Split('.').Last().SplitCamelCase();
+        //     if (CategoryImages.TryGetValue(category, out var image))
+        //     {
+        //         button.Content = new Image { Source = image.AsBitmapImage() };
+        //     }
+        //     else
+        //     {
+        //         button.Content = display;
+        //     }
+
+        //     button.Click += CatagoryButton_Click;
+        //     CategoryButtons.Add(category, button);
+        //     CategoryButtonPanel.Children.Add(button);
+        // }
+
+        // if (Properties.UseIconsForFormTypes)
+        // {
+        //     CategoryButtonPanel.Visibility = Visibility.Visible;
+        //     CategoryBox.Visibility = Visibility.Collapsed;
+        // }
+        // else
+        // {
+        //     CategoryButtonPanel.Visibility = Visibility.Collapsed;
+        //     CategoryBox.Visibility = Visibility.Visible;
+        // }
+
+        // FormBox = new ComboBox
+        // {
+        //     Width = 250,
+        //     VerticalContentAlignment = VerticalAlignment.Center,
+        //     Margin = new Thickness(0, 0, 5, 0),
+        //     IsEnabled = false
+        // };
+        // FormBox.SelectionChanged += FormBox_SelectionChanged;
+        // FormBox.ItemsSource = new Dictionary<DigitalForm, string> { };
+
+        // JobBox = new ComboBox
+        // {
+        //     Width = 250,
+        //     Margin = new Thickness(0, 0, 5, 0),
+        //     VerticalContentAlignment = VerticalAlignment.Center
+        // };
+        // JobBox.ItemsSource = Jobs.ToDictionary(x => x.ID, x => $"{x.JobNumber} : {x.Name}");
+        // JobBox.SelectedIndex = 0;
+        // JobBox.SelectedValuePath = "Key";
+        // JobBox.DisplayMemberPath = "Value";
+        // JobBox.SelectionChanged += JobBox_SelectionChanged;
+
+        // DateTypeBox = new ComboBox
+        // {
+        //     Width = 120,
+        //     VerticalContentAlignment = VerticalAlignment.Center
+        // };
+        // DateTypeBox.ItemsSource = FilterTypes;
+        // DateTypeBox.SelectedValuePath = "Key";
+        // DateTypeBox.DisplayMemberPath = "Value";
+        // DateTypeBox.SelectedValue = Properties.DateFilterType;
+        // DateTypeBox.SelectionChanged += DateTypeBox_SelectionChanged;
+
+        // FromLabel = new Label { Content = "From", VerticalContentAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 5, 0) };
+        // FromPicker = new DatePicker
+        // {
+        //     Width = 100,
+        //     Background = new SolidColorBrush(Colors.LightYellow),
+        //     VerticalContentAlignment = VerticalAlignment.Center,
+        //     FirstDayOfWeek = DayOfWeek.Monday,
+        //     Margin = new Thickness(0, 0, 5, 0)
+        // };
+        // FromPicker.SelectedDateChanged += FromPicker_SelectedDateChanged;
+
+        // ToLabel = new Label { Content = "To", VerticalContentAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 5, 0) };
+        // ToPicker = new DatePicker
+        // {
+        //     Width = 100,
+        //     Background = new SolidColorBrush(Colors.LightYellow),
+        //     VerticalContentAlignment = VerticalAlignment.Center,
+        //     FirstDayOfWeek = DayOfWeek.Monday,
+        //     Margin = new Thickness(0, 0, 5, 0)
+        // };
+        // ToPicker.SelectedDateChanged += ToPicker_SelectedDateChanged;
+
+        // IncompleteFormsBox = new ComboBox
+        // {
+        //     Width = 130,
+        //     Margin = new Thickness(0, 0, 5, 0),
+        //     VerticalContentAlignment = VerticalAlignment.Center
+        // };
+        // IncompleteFormsBox.ItemsSource = new List<Tuple<string, bool>>
+        // {
+        //     new Tuple<string, bool>("Completed Forms", false),
+        //     new Tuple<string, bool>("All Forms", true)
+        // };
+        // IncompleteFormsBox.DisplayMemberPath = "Item1";
+        // IncompleteFormsBox.SelectedValuePath = "Item2";
+        // IncompleteFormsBox.SelectedValue = Properties.ShowIncompleteForms;
+        // IncompleteFormsBox.SelectionChanged += IncompleteFormsBox_SelectionChanged;
+
+        // Print = new Button
+        // {
+        //     Width = 25,
+        //     Height = 25,
+        //     Content = new Image { Source = PRSDesktop.Resources.printer.AsBitmapImage() }
+        // };
+        // Print.Click += Print_Click;
+
+        // FilterBtn = new Button
+        // {
+        //     Width = 25,
+        //     Height = 25,
+        //     Content = new Image { Source = InABox.Wpf.Resources.filter.AsBitmapImage() },
+        //     Margin = new Thickness(0, 0, 5, 0)
+        // };
+        // FilterBtn.Click += Filter_Click;
+
+        // Header.BeginUpdate()
+        //     .Clear()
+        //     .Add(CategoryBox)
+        //     .Add(CategoryButtonPanel)
+        //     .Add(FormBox)
+        //     .Add(JobBox)
+        //     .Add(DateTypeBox)
+        //     .Add(FromLabel)
+        //     .Add(FromPicker)
+        //     .Add(ToLabel)
+        //     .Add(ToPicker)
+        //     .Add(IncompleteFormsBox)
+        //     .AddRight(FilterBtn)
+        //     .AddRight(Print)
+        //     .EndUpdate();
+
+        // UpdateCategory(Properties.Category);
+    }
 
-        public EquipmentSchedulesDashboard()
-        {
-            InitializeComponent();
-        }
+    #endregion
 
-        public void Setup()
+    private void LoadEmployeeImages()
+    {
+        Task.Run(() =>
         {
-            LoadEmployeeImages();
-        }
-
-        private void LoadEmployeeImages()
+            var employees = new Client<Employee>()
+                .Query(
+                    LookupFactory.DefineFilter<Employee>(),
+                    Columns.None<Employee>().Add(
+                        x => x.ID,
+                        x => x.Thumbnail.ID,
+                        x => x.Name,
+                        x => x.Mobile,
+                        x => x.Email))
+                .ToObjects<Employee>().ToList();
+            var documents = new Client<Document>()
+                .Query(
+                    new Filter<Document>(x => x.ID).InList(employees.Select(x => x.Thumbnail.ID).ToArray()),
+                    Columns.None<Document>().Add(x => x.ID).Add(x => x.Data))
+                .ToDictionary<Document, Guid, byte[]>(x => x.ID, x => x.Data);
+            return new { Employees = employees, Documents = documents };
+        }).ContinueWith((task) =>
         {
-            Task.Run(() =>
-            {
-                var employees = new Client<Employee>()
-                    .Query(
-                        LookupFactory.DefineFilter<Employee>(),
-                        Columns.None<Employee>().Add(
-                            x => x.ID,
-                            x => x.Thumbnail.ID,
-                            x => x.Name,
-                            x => x.Mobile,
-                            x => x.Email))
-                    .ToObjects<Employee>().ToList();
-                var documents = new Client<Document>()
-                    .Query(
-                        new Filter<Document>(x => x.ID).InList(employees.Select(x => x.Thumbnail.ID).ToArray()),
-                        Columns.None<Document>().Add(x => x.ID).Add(x => x.Data))
-                    .ToDictionary<Document, Guid, byte[]>(x => x.ID, x => x.Data);
-                return new { Employees = employees, Documents = documents };
-            }).ContinueWith((task) =>
+            EmployeeImages = task.Result.Employees.ToDictionary(
+                x => x.ID,
+                x =>
+                {
+                    var document = task.Result.Documents.GetValueOrDefault(x.Thumbnail.ID);
+                    if (document is null)
+                        return null;
+
+                    return ImageUtils.BitmapImageFromBytes(document);
+                });
+            Employees = task.Result.Employees.ToDictionary(x => x.ID, x => x);
+            lock (Models)
             {
-                EmployeeImages = task.Result.Employees.ToDictionary(
-                    x => x.ID,
-                    x =>
-                    {
-                        var document = task.Result.Documents.GetValueOrDefault(x.Thumbnail.ID);
-                        if (document is null)
-                            return null;
-
-                        return ImageUtils.BitmapImageFromBytes(document);
-                    });
-                Employees = task.Result.Employees.ToDictionary(x => x.ID, x => x);
-                lock (Models)
+                var anonymous = PRSDesktop.Resources.anonymous.AsBitmapImage();
+                foreach (var model in Models)
                 {
-                    var anonymous = PRSDesktop.Resources.anonymous.AsBitmapImage();
-                    foreach (var model in Models)
+                    foreach (var schedule in model.Schedules)
                     {
-                        foreach (var schedule in model.Schedules)
-                        {
-                            var employee = Employees?.GetValueOrDefault(schedule.EmployeeID);
-                            schedule.EmployeeImage = EmployeeImages?.GetValueOrDefault(schedule.EmployeeID) ?? anonymous;
-                            schedule.EmployeeMobile = employee?.Mobile;
-                            schedule.EmployeeName = employee?.Name;
-                            schedule.EmployeeEmail = employee?.Email;
-                        }
+                        var employee = Employees?.GetValueOrDefault(schedule.EmployeeID);
+                        schedule.EmployeeImage = EmployeeImages?.GetValueOrDefault(schedule.EmployeeID) ?? anonymous;
+                        schedule.EmployeeMobile = employee?.Mobile;
+                        schedule.EmployeeName = employee?.Name;
+                        schedule.EmployeeEmail = employee?.Email;
                     }
                 }
-            }, TaskScheduler.FromCurrentSynchronizationContext());
-        }
+            }
+        }, TaskScheduler.FromCurrentSynchronizationContext());
+    }
 
-        public void Refresh()
+    public void Refresh()
+    {
+        var results = Client.QueryMultiple(
+            new KeyedQueryDef<Equipment>(
+                new Filter<Equipment>().All(),
+                Columns.None<Equipment>().Add(x => x.ID)
+                    .Add(x => x.Code)
+                    .Add(x => x.Description)
+                    .Add(x => x.TrackerLink.ID)
+                    .Add(x => x.TrackerLink.Location.Latitude)
+                    .Add(x => x.TrackerLink.Location.Longitude)
+                    .Add(x => x.TrackerLink.Location.Timestamp)),
+            new KeyedQueryDef<Schedule>(
+                new Filter<Schedule>(x => x.DocumentClass).IsEqualTo(typeof(Equipment).EntityName())
+                    .And(x => x.IncludeInAggregate).IsEqualTo(true),
+                Columns.None<Schedule>().Add(x => x.ID)
+                    .Add(x => x.Title)
+                    .Add(x => x.DueDate)
+                    .Add(x => x.DocumentID)
+                    .Add(x => x.EmployeeLink.ID)));
+
+        var equipmentItems = results.Get<Equipment>().Rows.Select(x => x.ToObject<Equipment>());
+        Equipment = equipmentItems.ToDictionary(x => x.ID, x => x);
+        var schedules = results.Get<Schedule>().Rows
+            .Select(x => x.ToObject<Schedule>())
+            .GroupBy(x => x.DocumentID)
+            .ToDictionary(x => x.Key, x => x.OrderBy(x => x.DueDate).ToList());
+
+        var anonymous = PRSDesktop.Resources.anonymous.AsBitmapImage();
+
+        lock (Models)
         {
-            var results = Client.QueryMultiple(
-                new KeyedQueryDef<Equipment>(
-                    new Filter<Equipment>().All(),
-                    Columns.None<Equipment>().Add(x => x.ID)
-                        .Add(x => x.Code)
-                        .Add(x => x.Description)
-                        .Add(x => x.TrackerLink.ID)
-                        .Add(x => x.TrackerLink.Location.Latitude)
-                        .Add(x => x.TrackerLink.Location.Longitude)
-                        .Add(x => x.TrackerLink.Location.Timestamp)),
-                new KeyedQueryDef<Schedule>(
-                    new Filter<Schedule>(x => x.DocumentClass).IsEqualTo(typeof(Equipment).EntityName())
-                        .And(x => x.IncludeInAggregate).IsEqualTo(true),
-                    Columns.None<Schedule>().Add(x => x.ID)
-                        .Add(x => x.Title)
-                        .Add(x => x.DueDate)
-                        .Add(x => x.DocumentID)
-                        .Add(x => x.EmployeeLink.ID)));
-
-            var equipmentItems = results.Get<Equipment>().Rows.Select(x => x.ToObject<Equipment>());
-            Equipment = equipmentItems.ToDictionary(x => x.ID, x => x);
-            var schedules = results.Get<Schedule>().Rows
-                .Select(x => x.ToObject<Schedule>())
-                .GroupBy(x => x.DocumentID)
-                .ToDictionary(x => x.Key, x => x.OrderBy(x => x.DueDate).ToList());
-
-            var anonymous = PRSDesktop.Resources.anonymous.AsBitmapImage();
-
-            lock (Models)
+            Models = new List<EquipmentScheduleViewModel>();
+            foreach (var equipmentItem in equipmentItems)
             {
-                Models = new List<EquipmentScheduleViewModel>();
-                foreach (var equipmentItem in equipmentItems)
+                var equipmentSchedules = schedules.GetValueOrDefault(equipmentItem.ID);
+                var model = new EquipmentScheduleViewModel
                 {
-                    var equipmentSchedules = schedules.GetValueOrDefault(equipmentItem.ID);
-                    if (equipmentSchedules is not null)
+                    Code = equipmentItem.Code,
+                    Description = equipmentItem.Description,
+                    ID = equipmentItem.ID,
+                    HasLocation = equipmentItem.TrackerLink.ID != Guid.Empty
+                };
+
+                model.Schedules = (equipmentSchedules ?? Enumerable.Empty<Schedule>())
+                    .Select(x =>
                     {
-                        var model = new EquipmentScheduleViewModel
+                        var employee = Employees.GetValueOrDefault(x.EmployeeLink.ID);
+                        return new ScheduleViewModel
                         {
-                            Code = equipmentItem.Code,
-                            Description = equipmentItem.Description,
-                            ID = equipmentItem.ID,
-                            HasLocation = equipmentItem.TrackerLink.ID != Guid.Empty
+                            Title = x.Title,
+                            DueDate = x.DueDate,
+                            ID = x.ID,
+                            EmployeeImage = EmployeeImages.GetValueOrDefault(x.EmployeeLink.ID) ?? anonymous,
+                            EmployeeID = x.EmployeeLink.ID,
+                            EmployeeEmail = employee?.Email,
+                            EmployeeMobile = employee?.Mobile,
+                            EmployeeName = employee?.Name
                         };
+                    })
+                    .ToList() ?? [];
 
-                        model.Schedules = equipmentSchedules
-                            .Select(x =>
-                            {
-                                var employee = Employees.GetValueOrDefault(x.EmployeeLink.ID);
-                                return new ScheduleViewModel
-                                {
-                                    Title = x.Title,
-                                    DueDate = x.DueDate,
-                                    ID = x.ID,
-                                    EmployeeImage = EmployeeImages.GetValueOrDefault(x.EmployeeLink.ID) ?? anonymous,
-                                    EmployeeID = x.EmployeeLink.ID,
-                                    EmployeeEmail = employee?.Email,
-                                    EmployeeMobile = employee?.Mobile,
-                                    EmployeeName = employee?.Name
-                                };
-                            })
-                            .ToList() ?? new List<ScheduleViewModel>();
-
-                        Models.Add(model);
-                    }
-                }
+                Models.Add(model);
             }
-            EquipmentList.ItemsSource = Models;
         }
+        EquipmentList.ItemsSource = Models;
+    }
 
-        public void Shutdown(CancelEventArgs? cancel)
-        {
-        }
+    public void Shutdown(CancelEventArgs? cancel)
+    {
+    }
 
-        private void ViewEquipment_Click(object sender, System.Windows.RoutedEventArgs e)
-        {
-            var equipmentID = (Guid)(sender as MenuItem)!.Tag;
+    private void ViewEquipment_Click(object sender, System.Windows.RoutedEventArgs e)
+    {
+        var equipmentID = (Guid)(sender as MenuItem)!.Tag;
 
-            var equipment = new Client<Equipment>().Load(
-                new Filter<Equipment>(x => x.ID).IsEqualTo(equipmentID)).FirstOrDefault();
-            if(equipment != null)
+        var equipment = new Client<Equipment>().Load(
+            new Filter<Equipment>(x => x.ID).IsEqualTo(equipmentID)).FirstOrDefault();
+        if(equipment != null)
+        {
+            var grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(Equipment));
+            if(grid.EditItems(new[] { equipment }))
             {
-                var grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(Equipment));
-                if(grid.EditItems(new[] { equipment }))
-                {
-                    new Client<Equipment>().Save(equipment, "Edited by user from schedules dashboard");
-                    Refresh();
-                }
+                new Client<Equipment>().Save(equipment, "Edited by user from schedules dashboard");
+                Refresh();
             }
         }
+    }
 
-        private void ViewSchedule_Click(object sender, System.Windows.RoutedEventArgs e)
-        {
-            var scheduleID = (Guid)(sender as MenuItem)!.Tag;
+    private void ViewSchedule_Click(object sender, System.Windows.RoutedEventArgs e)
+    {
+        var scheduleID = (Guid)(sender as MenuItem)!.Tag;
 
-            var schedule = new Client<Schedule>().Load(
-                new Filter<Schedule>(x => x.ID).IsEqualTo(scheduleID)).FirstOrDefault();
-            if (schedule != null)
+        var schedule = new Client<Schedule>().Load(
+            new Filter<Schedule>(x => x.ID).IsEqualTo(scheduleID)).FirstOrDefault();
+        if (schedule != null)
+        {
+            var grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(Schedule));
+            if (grid.EditItems(new[] { schedule }))
             {
-                var grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(Schedule));
-                if (grid.EditItems(new[] { schedule }))
-                {
-                    new Client<Schedule>().Save(schedule, "Edited by user from schedules dashboard");
-                    Refresh();
-                }
+                new Client<Schedule>().Save(schedule, "Edited by user from schedules dashboard");
+                Refresh();
             }
         }
+    }
 
-        private void ViewEmployee_Click(object sender, System.Windows.RoutedEventArgs e)
-        {
-            var employeeID = (Guid)(sender as MenuItem)!.Tag;
+    private void ViewEmployee_Click(object sender, System.Windows.RoutedEventArgs e)
+    {
+        var employeeID = (Guid)(sender as MenuItem)!.Tag;
 
-            var employee = new Client<Employee>().Load(
-                new Filter<Employee>(x => x.ID).IsEqualTo(employeeID)).FirstOrDefault();
-            if (employee != null)
+        var employee = new Client<Employee>().Load(
+            new Filter<Employee>(x => x.ID).IsEqualTo(employeeID)).FirstOrDefault();
+        if (employee != null)
+        {
+            var grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(Employee));
+            if (grid.EditItems(new[] { employee }))
             {
-                var grid = DynamicGridUtils.CreateDynamicGrid(typeof(DynamicDataGrid<>), typeof(Employee));
-                if (grid.EditItems(new[] { employee }))
-                {
-                    new Client<Employee>().Save(employee, "Edited by user from schedules dashboard");
-                    Refresh();
-                }
+                new Client<Employee>().Save(employee, "Edited by user from schedules dashboard");
+                Refresh();
             }
         }
+    }
 
-        private void EquipmentLocation_Click(object sender, System.Windows.RoutedEventArgs e)
-        {
-            var equipmentID = (Guid)(sender as Button)!.Tag;
+    private void EquipmentLocation_Click(object sender, System.Windows.RoutedEventArgs e)
+    {
+        var equipmentID = (Guid)(sender as Button)!.Tag;
 
-            if (!Equipment.TryGetValue(equipmentID, out var equipment))
-                return;
+        if (!Equipment.TryGetValue(equipmentID, out var equipment))
+            return;
 
-            var form = new MapForm(
-                equipment.TrackerLink.Location.Latitude,
-                equipment.TrackerLink.Location.Longitude,
-                equipment.TrackerLink.Location.Timestamp);
-            form.ShowDialog();
-        }
+        var form = new MapForm(
+            equipment.TrackerLink.Location.Latitude,
+            equipment.TrackerLink.Location.Longitude,
+            equipment.TrackerLink.Location.Timestamp);
+        form.ShowDialog();
     }
-
-    public class EquipmentSchedulesDashboardElement : 
-        DashboardElement<EquipmentSchedulesDashboard, EquipmentDashboardGroup, EquipmentSchedulesDashboardProperties> { }
 }
+
+public class EquipmentSchedulesDashboardElement : 
+    DashboardElement<EquipmentSchedulesDashboard, EquipmentDashboardGroup, EquipmentSchedulesDashboardProperties> { }