btcpayserver/BTCPayServer.Data/Data/InvoiceEventData.cs

52 lines
1.4 KiB
C#
Raw Normal View History

using System;
using Microsoft.EntityFrameworkCore;
2018-01-14 13:48:23 +01:00
namespace BTCPayServer.Data
{
public class InvoiceEventData
{
public string InvoiceDataId { get; set; }
public InvoiceData InvoiceData { get; set; }
public string UniqueId { get; set; }
public DateTimeOffset Timestamp { get; set; }
2018-01-14 13:48:23 +01:00
public string Message { get; set; }
public EventSeverity Severity { get; set; } = EventSeverity.Info;
internal static void OnModelCreating(ModelBuilder builder)
{
builder.Entity<InvoiceEventData>()
.HasOne(o => o.InvoiceData)
.WithMany(i => i.Events).OnDelete(DeleteBehavior.Cascade);
builder.Entity<InvoiceEventData>()
.HasKey(o => new
{
o.InvoiceDataId,
#pragma warning disable CS0618
o.UniqueId
#pragma warning restore CS0618
});
}
public enum EventSeverity
{
Info,
Error,
Success,
Warning
}
public string GetCssClass()
{
return Severity switch
{
EventSeverity.Info => "info",
EventSeverity.Error => "danger",
EventSeverity.Success => "success",
EventSeverity.Warning => "warning",
_ => null
};
}
2018-01-14 13:48:23 +01:00
}
}