From 091390fcad1c781fc87937dd882147efe0e92bae Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Fri, 17 Apr 2026 12:35:14 -0400 Subject: [PATCH] Calculate lastUpdated from comments, audit log, and modification time - Takes the max of: LastModificationTime, latest comment CreatedDate, latest audit log CreatedAt - Reflects any comment (customer/vendor/internal) or status change --- Api.SeaHavenIndustries/Controllers/WorkOrderController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs b/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs index 8ad8fae..929d29a 100644 --- a/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs +++ b/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs @@ -411,7 +411,11 @@ namespace Api.SeaHavenIndustries.Controllers dueDate = w.DueDate, assignedTo = w.AssignToUser != null ? w.AssignToUser.FirstName + " " + w.AssignToUser.LastName : "", employeeName = w.AssignToUser != null ? w.AssignToUser.FirstName + " " + w.AssignToUser.LastName : "", - lastUpdated = w.LastModificationTime + lastUpdated = new[] { + w.LastModificationTime, + w.Comments.Max(c => (DateTime?)c.CreatedDate), + _db.WorkOrderAuditLogs.Where(a => a.WorkOrderId == w.Id).Max(a => (DateTime?)a.CreatedAt) + }.Where(d => d.HasValue).Max() }) .ToList();