using PostFundManagement.Domain.Abstractions; namespace PostFundManagement.Domain.Entities; [EntityTypeConfiguration] public class Notification : Models.Notification, ITenantEntity { public virtual Tenant? Tenant { get; set; } public virtual Organisation? Organisation { get; set; } public virtual User? RecipientUser { get; set; } } public sealed class NotificationConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(Notification).Pluralize()); builder.HasKey(pk => pk.Id); builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()"); builder.Property(f => f.UpdatedAt).IsRequired(false); builder.Property(f => f.SentAt).IsRequired(false); builder.Property(f => f.Recipient).IsRequired(); builder.Property(f => f.OrganisationId).IsRequired(); builder.Property(f => f.TenantId).IsRequired(); builder.Property(f => f.Platform).IsRequired().HasConversion().HasDefaultValueSql("1") .HasSentinel(NotificationPlatform.Email); builder.Property(f => f.Status).IsRequired().HasConversion().HasDefaultValueSql("1") .HasSentinel(NotificationStatus.Pending); builder.Property(f => f.Subject).IsRequired(false).HasMaxLength(LabelLength); builder.Property(f => f.Message).IsRequired().HasMaxLength(LargeTextLength); builder.Property(f => f.Destination).IsRequired().HasMaxLength(LabelLength); builder.Property(f => f.Error).IsRequired(false); builder.HasOne(f => f.Tenant) .WithMany() .HasForeignKey(fk => fk.TenantId) .IsRequired() .OnDelete(DeleteBehavior.Restrict); builder.HasOne(f => f.Organisation) .WithMany() .HasForeignKey(fk => fk.OrganisationId) .IsRequired() .OnDelete(DeleteBehavior.Restrict); builder.HasOne(f => f.RecipientUser) .WithMany() .HasForeignKey(fk => fk.Recipient) .IsRequired() .OnDelete(DeleteBehavior.Restrict); } }