mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-01 23:13:22 +00:00
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
using Data.SeaHavenIndustries.Enums;
|
|
|
|
namespace SeaHaven.Services.Helpers
|
|
{
|
|
public static class LifecycleStatusMapper
|
|
{
|
|
public static LifecycleStatus? FromLegacyStatus(string? status)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(status)) return null;
|
|
|
|
return status.Trim().ToLowerInvariant() switch
|
|
{
|
|
"open" => LifecycleStatus.Incomplete,
|
|
"inprogress" or "in progress" => LifecycleStatus.InProgress,
|
|
"completed" or "complete" => LifecycleStatus.Complete,
|
|
"cancelled" or "canceled" => LifecycleStatus.Canceled,
|
|
"onhold" or "on hold" => LifecycleStatus.OnHold,
|
|
"scheduled" => LifecycleStatus.Scheduled,
|
|
"pendingvendor" or "pending vendor" => LifecycleStatus.PendingVendor,
|
|
"pendingapproval" or "pending approval" => LifecycleStatus.PendingApproval,
|
|
"needsreview" or "needs review" => LifecycleStatus.NeedsReview,
|
|
"closed" => LifecycleStatus.Closed,
|
|
_ => LifecycleStatus.NeedsReview
|
|
};
|
|
}
|
|
|
|
public static LifecycleStatus? ParseLifecycleStatus(string? value)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(value)) return null;
|
|
if (Enum.TryParse<LifecycleStatus>(value, true, out var parsed)) return parsed;
|
|
return FromLegacyStatus(value);
|
|
}
|
|
}
|
|
}
|