22 lines
816 B
C#
22 lines
816 B
C#
public enum AlertStatus { Open, Acknowledged, Resolved, Escalated }
|
|
|
|
public static class AlertStatusExtensions
|
|
{
|
|
public static string ToDbString(this AlertStatus s) => s switch
|
|
{
|
|
AlertStatus.Open => "OPEN",
|
|
AlertStatus.Acknowledged => "ACKNOWLEDGED",
|
|
AlertStatus.Resolved => "RESOLVED",
|
|
AlertStatus.Escalated => "ESCALATED",
|
|
_ => throw new ArgumentOutOfRangeException(nameof(s))
|
|
};
|
|
|
|
public static AlertStatus FromDbString(string v) => v switch
|
|
{
|
|
"OPEN" => AlertStatus.Open,
|
|
"ACKNOWLEDGED" => AlertStatus.Acknowledged,
|
|
"RESOLVED" => AlertStatus.Resolved,
|
|
"ESCALATED" => AlertStatus.Escalated,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown alert status: '{v}'")
|
|
};
|
|
} |