using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using ScadaLink.Commons.Entities.Notifications; namespace ScadaLink.ConfigurationDatabase.Configurations; public class NotificationListConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(n => n.Id); builder.Property(n => n.Name) .IsRequired() .HasMaxLength(200); builder.HasMany(n => n.Recipients) .WithOne() .HasForeignKey(r => r.NotificationListId) .OnDelete(DeleteBehavior.Cascade); builder.HasIndex(n => n.Name).IsUnique(); } } public class NotificationRecipientConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(r => r.Id); builder.Property(r => r.Name) .IsRequired() .HasMaxLength(200); builder.Property(r => r.EmailAddress) .IsRequired() .HasMaxLength(500); } } public class SmtpConfigurationConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasKey(s => s.Id); builder.Property(s => s.Host) .IsRequired() .HasMaxLength(500); builder.Property(s => s.AuthType) .IsRequired() .HasMaxLength(50); // Stored encrypted at rest (EncryptedStringConverter). Ciphertext is larger than // the plaintext, so the column is sized generously to avoid truncation. builder.Property(s => s.Credentials) .HasMaxLength(8000); builder.Property(s => s.TlsMode) .HasMaxLength(50); builder.Property(s => s.FromAddress) .IsRequired() .HasMaxLength(500); } }