From a675e4a6e921c6178fd26074cf505f9ab25f6a53 Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Thu, 28 Mar 2024 11:30:39 +1100 Subject: [PATCH] Feature: Provide `CurrentDeviceUserAssignments` for use by document expressions --- Disco.Models/Repository/Device/Device.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Disco.Models/Repository/Device/Device.cs b/Disco.Models/Repository/Device/Device.cs index c0c515df..f4ce4d23 100644 --- a/Disco.Models/Repository/Device/Device.cs +++ b/Disco.Models/Repository/Device/Device.cs @@ -53,6 +53,21 @@ namespace Disco.Models.Repository public virtual IList Jobs { get; set; } public virtual IList DeviceFlagAssignments { get; set; } + /// + /// A list of the current device assignments, ordered by the most recent assignment date. + /// + [NotMapped] + public IList CurrentDeviceUserAssignments + { + get + { + return DeviceUserAssignments? + .Where(dua => dua.UnassignedDate is null) + .OrderByDescending(dua => dua.AssignedDate) + .ToList(); + } + } + public override string ToString() { if (DeviceModel != null)