Files
pfm/PostFundManagement.Domain/Entities/Outcome.cs
T
2026-10-22 15:42:36 +02:00

50 lines
1.7 KiB
C#

using PostFundManagement.Domain.Abstractions;
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<OutcomeConfiguration, Outcome>]
public class Outcome : Models.Outcome, ITenantEntity
{
public virtual Tenant? Tenant { get; set; }
public virtual Beneficiary? Beneficiary { get; set; }
public virtual User? Creator { get; set; }
}
public sealed class OutcomeConfiguration : IEntityTypeConfiguration<Outcome>
{
public void Configure(EntityTypeBuilder<Outcome> builder)
{
builder.ToTable(nameof(Outcome).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.TenantId).IsRequired();
builder.Property(f => f.BeneficiaryId).IsRequired();
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Description).IsRequired().HasMaxLength(TextLength);
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1")
.HasSentinel(ComplianceStatus.NotMet);
builder.HasOne(f => f.Tenant)
.WithMany()
.HasForeignKey(fk => fk.TenantId)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Beneficiary)
.WithMany()
.HasForeignKey(fk => fk.BeneficiaryId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(fk => fk.CreatedBy)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
}
}