public enum GatewayStatus { Online, Degraded, Offline }

public static class GatewayStatusExtensions
{
    public static string ToDbString(this GatewayStatus s) => s switch
    {
        GatewayStatus.Online   => "ONLINE",
        GatewayStatus.Degraded => "DEGRADED",
        GatewayStatus.Offline  => "OFFLINE",
        _ => throw new ArgumentOutOfRangeException(nameof(s))
    };

    public static GatewayStatus FromDbString(string v) => v switch
    {
        "ONLINE"   => GatewayStatus.Online,
        "DEGRADED" => GatewayStatus.Degraded,
        "OFFLINE"  => GatewayStatus.Offline,
        _ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown gateway status: '{v}'")
    };
}