2020-06-24 10:23:16 +02:00
|
|
|
using System;
|
2020-06-27 14:55:16 +02:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2018-01-14 13:48:23 +01:00
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
|
|
|
public class InvoiceEventData
|
|
|
|
{
|
2020-12-28 21:57:21 +01:00
|
|
|
public string InvoiceDataId { get; set; }
|
|
|
|
public InvoiceData InvoiceData { get; set; }
|
2019-08-29 17:24:42 +02:00
|
|
|
public string UniqueId { get; set; }
|
2020-12-28 21:57:21 +01:00
|
|
|
public DateTimeOffset Timestamp { get; set; }
|
2018-01-14 13:48:23 +01:00
|
|
|
public string Message { get; set; }
|
2020-08-28 08:49:13 +02:00
|
|
|
public EventSeverity Severity { get; set; } = EventSeverity.Info;
|
2020-06-27 14:55:16 +02:00
|
|
|
|
2020-12-28 21:57:21 +01:00
|
|
|
|
2020-06-27 14:55:16 +02:00
|
|
|
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
|
|
|
|
});
|
|
|
|
}
|
2020-12-28 21:57:21 +01:00
|
|
|
|
2020-08-28 08:49:13 +02:00
|
|
|
public enum EventSeverity
|
|
|
|
{
|
|
|
|
Info,
|
|
|
|
Error,
|
|
|
|
Success,
|
|
|
|
Warning
|
|
|
|
}
|
2020-12-28 21:57:21 +01:00
|
|
|
|
2020-08-28 08:49:13 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|