btcpayserver/BTCPayServer.Data/Data/NotificationData.cs

42 lines
1.4 KiB
C#
Raw Normal View History

2020-06-28 21:44:35 -05:00
using System;
2020-06-12 00:16:50 -05:00
using System.ComponentModel.DataAnnotations;
2020-05-28 15:15:24 -05:00
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
2020-05-28 15:15:24 -05:00
namespace BTCPayServer.Data
{
public class NotificationData : IHasBlobUntyped
{
2020-06-12 00:16:50 -05:00
[MaxLength(36)]
public string Id { get; set; }
public DateTimeOffset Created { get; set; }
2020-06-12 00:16:50 -05:00
[MaxLength(50)]
2020-06-25 15:43:45 +09:00
[Required]
public string ApplicationUserId { get; set; }
2020-05-28 15:15:24 -05:00
public ApplicationUser ApplicationUser { get; set; }
2020-06-12 00:16:50 -05:00
[MaxLength(100)]
2020-06-25 15:43:45 +09:00
[Required]
public string NotificationType { get; set; }
public bool Seen { get; set; }
[Obsolete("Use Blob2 instead")]
public byte[] Blob { get; set; }
public string Blob2 { get; set; }
2020-05-28 15:15:24 -05:00
2023-04-10 11:07:03 +09:00
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
{
2020-05-28 15:15:24 -05:00
builder.Entity<NotificationData>()
.HasOne(o => o.ApplicationUser)
.WithMany(n => n.Notifications)
2020-06-13 18:45:44 -05:00
.HasForeignKey(k => k.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
if (databaseFacade.IsNpgsql())
{
builder.Entity<NotificationData>()
.Property(o => o.Blob2)
.HasColumnType("JSONB");
}
2020-05-28 15:15:24 -05:00
}
}
}