From f89db3da52b173c6e2c0e55bf9817fae93380b7a Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Fri, 17 Apr 2026 12:57:37 -0400 Subject: [PATCH] Add server-side status and assignee filters to GetWorkOrderList - Accept status and assignee query parameters - Filter in SQL before counting and paginating - Supports __unassigned for unassigned work orders - Accurate totalCount reflects filtered results --- .../Controllers/WorkOrderController.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs b/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs index 0bb4a43..c567180 100644 --- a/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs +++ b/Api.SeaHavenIndustries/Controllers/WorkOrderController.cs @@ -369,7 +369,7 @@ namespace Api.SeaHavenIndustries.Controllers // GET: api/WorkOrder/GetWorkOrderList // ----------------------------------- [HttpGet("GetWorkOrderList")] - public IActionResult GetWorkOrderList(string? search = "", int page = 1, int pageSize = 12, string? sortBy = "lastUpdated", string? sortDir = "desc") + public IActionResult GetWorkOrderList(string? search = "", int page = 1, int pageSize = 12, string? sortBy = "lastUpdated", string? sortDir = "desc", string? status = "", string? assignee = "") { search ??= ""; @@ -378,6 +378,14 @@ namespace Api.SeaHavenIndustries.Controllers .Include(w => w.AssignToUser) .Where(w => w.istemplate != true); + if (!string.IsNullOrWhiteSpace(status)) + query = query.Where(w => w.Status == status); + + if (assignee == "__unassigned") + query = query.Where(w => w.AssignTo == null || w.AssignTo == ""); + else if (!string.IsNullOrWhiteSpace(assignee)) + query = query.Where(w => w.AssignToUser != null && (w.AssignToUser.FirstName + " " + w.AssignToUser.LastName).Contains(assignee)); + if (!string.IsNullOrWhiteSpace(search)) { var s = search.ToLower();