2026-06-30 10:09:48 -03:00
|
|
|
|
using Data.SeaHavenIndustries.Enums;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SeaHaven.Services.Helpers
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class WorkOrderDerivedFields
|
|
|
|
|
|
{
|
|
|
|
|
|
public static bool IsPastDue(
|
|
|
|
|
|
DateTime? scheduledDate,
|
|
|
|
|
|
LifecycleStatus? lifecycleStatus,
|
|
|
|
|
|
DateTime? utcNow = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!scheduledDate.HasValue)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
2026-07-07 13:11:22 -03:00
|
|
|
|
if (LifecycleStatusMapper.IsTerminal(lifecycleStatus))
|
2026-06-30 10:09:48 -03:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
var today = (utcNow ?? DateTime.UtcNow).Date;
|
|
|
|
|
|
return scheduledDate.Value.Date < today;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool IsTerminal(LifecycleStatus? lifecycleStatus)
|
2026-07-07 13:11:22 -03:00
|
|
|
|
=> LifecycleStatusMapper.IsTerminal(lifecycleStatus);
|
2026-06-30 10:09:48 -03:00
|
|
|
|
|
|
|
|
|
|
public static string? GetDayGroup(DateTime? scheduledDate)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!scheduledDate.HasValue)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
return scheduledDate.Value.DayOfWeek switch
|
|
|
|
|
|
{
|
|
|
|
|
|
DayOfWeek.Monday => "monday",
|
|
|
|
|
|
DayOfWeek.Tuesday => "tuesday",
|
|
|
|
|
|
DayOfWeek.Wednesday => "wednesday",
|
|
|
|
|
|
DayOfWeek.Thursday => "thursday",
|
|
|
|
|
|
DayOfWeek.Friday => "friday",
|
|
|
|
|
|
_ => null
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string? FormatApptTime(DateTime? start, DateTime? end)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!start.HasValue)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
if (end.HasValue)
|
|
|
|
|
|
return $"{start.Value:HH:mm} – {end.Value:HH:mm}";
|
|
|
|
|
|
|
|
|
|
|
|
return start.Value.ToString("HH:mm");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetLifecycleStatusLabel(LifecycleStatus? status)
|
2026-07-07 13:11:22 -03:00
|
|
|
|
=> status.HasValue ? LifecycleStatusMapper.ToFeLabel(status.Value) : "";
|
2026-06-30 10:09:48 -03:00
|
|
|
|
}
|
|
|
|
|
|
}
|