mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 11:53:12 +00:00
30 lines
852 B
C#
30 lines
852 B
C#
|
|
namespace SeaHaven.Services.Helpers
|
||
|
|
{
|
||
|
|
public static class WorkOrderBoardSortFields
|
||
|
|
{
|
||
|
|
public static readonly IReadOnlySet<string> Allowed = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||
|
|
{
|
||
|
|
"scheduledDate",
|
||
|
|
"woNumber",
|
||
|
|
"dueDate"
|
||
|
|
};
|
||
|
|
|
||
|
|
public static string NormalizeOrThrow(string? sortBy)
|
||
|
|
{
|
||
|
|
var field = (sortBy ?? "scheduledDate").Trim();
|
||
|
|
if (!Allowed.Contains(field))
|
||
|
|
{
|
||
|
|
throw new ArgumentException(
|
||
|
|
"sortBy must be one of: scheduledDate, woNumber, dueDate.");
|
||
|
|
}
|
||
|
|
|
||
|
|
return field.ToLowerInvariant() switch
|
||
|
|
{
|
||
|
|
"wonumber" => "woNumber",
|
||
|
|
"duedate" => "dueDate",
|
||
|
|
_ => "scheduledDate"
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|