using System.Text.RegularExpressions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Authinator.Backend.Database.Tables; public record ACL { public int Id { get; set; } public string Name { get; set; } = null!; public bool Enabled { get; set; } = true; public string Target { get; set; } = null!; public bool TargetIsRegex { get; set; } public List Users { get; set; } = new(); public List Groups { get; set; } = new(); public List Networks { get; set; } = new(); public class Configuration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder acl) { acl.ToTable("ACLs"); acl.HasKey(p => p.Id); acl.Property(b => b.Name).HasColumnName("Name").IsRequired(); acl.Property(p => p.Target).HasColumnName("Target").IsRequired(); acl.Property(p => p.Enabled).HasColumnName("Enabled").IsRequired(); acl.Property(p => p.TargetIsRegex).HasColumnName("TargetIsRegex").HasDefaultValue(false); acl.HasMany(p => p.Networks).WithMany(); acl.HasMany(p => p.Groups).WithMany(); acl.HasMany(p => p.Users).WithMany(); } } }