mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 08:23:12 +00:00
34 lines
992 B
C#
34 lines
992 B
C#
using Data.SeaHavenIndustries.Enums;
|
|
|
|
namespace SeaHaven.Services.Helpers
|
|
{
|
|
public static class WorkOrderSeverityRules
|
|
{
|
|
public static bool TypeRequiresSeverity(WorkOrderType? type)
|
|
=> type is WorkOrderType.Emergency or WorkOrderType.Reactive;
|
|
|
|
public static bool TryNormalize(string? value, out string? normalized)
|
|
{
|
|
normalized = null;
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
return true;
|
|
|
|
var trimmed = value.Trim();
|
|
if (trimmed is "1" or "2" or "3" or "4" or "5")
|
|
{
|
|
normalized = trimmed;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static int? ParseLevel(string? stored)
|
|
{
|
|
if (!TryNormalize(stored, out var normalized) || normalized == null)
|
|
return null;
|
|
|
|
return int.Parse(normalized, System.Globalization.CultureInfo.InvariantCulture);
|
|
}
|
|
}
|
|
}
|