btcpayserver/BTCPayServer/Models/StatusMessageModel.cs
2020-06-24 10:34:09 +09:00

53 lines
1.4 KiB
C#

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Models
{
public class StatusMessageModel
{
public StatusMessageModel()
{
}
public string Message { get; set; }
public string Html { get; set; }
public StatusSeverity Severity { get; set; }
public bool AllowDismiss { get; set; } = true;
public string SeverityCSS => ToString(Severity);
private void ParseNonJsonStatus(string s)
{
Message = s;
Severity = s.StartsWith("Error", StringComparison.InvariantCultureIgnoreCase)
? StatusSeverity.Error
: StatusSeverity.Success;
}
public static string ToString(StatusSeverity severity)
{
switch (severity)
{
case StatusSeverity.Info:
return "info";
case StatusSeverity.Error:
return "danger";
case StatusSeverity.Success:
return "success";
case StatusSeverity.Warning:
return "warning";
default:
throw new ArgumentOutOfRangeException();
}
}
public enum StatusSeverity
{
Info,
Error,
Success,
Warning
}
}
}