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
This commit is contained in:
Adam Moussa 2026-04-17 12:35:14 -04:00
parent 0a564499f5
commit 091390fcad

View file

@ -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();