Files
hermes 020bdee36f Stable run using Multi tenancy across entire estate
Audit logging and error logging active
2026-09-24 12:00:47 +02:00

75 lines
2.5 KiB
C#

using PostFundManagement.Domain.Abstractions;
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<InviteConfiguration, Invite>]
public class Invite : Models.Invite, ITenantEntity
{
public virtual Tenant? Tenant { get; set; }
public virtual Organisation? Organisation { get; set; }
public virtual Organisation? InvitedOrganisation { get; set; }
public virtual Award? Award { get; set; }
public virtual Contract? Contract { get; set; }
public virtual User? RecipientUser { get; set; }
}
public sealed class InviteConfiguration : IEntityTypeConfiguration<Invite>
{
public void Configure(EntityTypeBuilder<Invite> builder)
{
builder.ToTable(nameof(Invite).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.TenantId).IsRequired();
builder.Property(f => f.OrganisationId).IsRequired();
builder.Property(f => f.InvitedOrganisationId).IsRequired();
builder.Property(f => f.AwardId).IsRequired();
builder.Property(f => f.ContractId).IsRequired();
builder.Property(f => f.Recipient).IsRequired();
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.UpdatedBy).IsRequired(false);
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.UpdatedAt).IsRequired(false);
builder.HasOne(f => f.Tenant)
.WithMany()
.HasForeignKey(fk => fk.TenantId)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Organisation)
.WithMany()
.HasForeignKey(fk => fk.OrganisationId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.InvitedOrganisation)
.WithMany()
.HasForeignKey(fk => fk.InvitedOrganisationId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Award)
.WithMany()
.HasForeignKey(fk => fk.AwardId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Contract)
.WithMany()
.HasForeignKey(fk => fk.ContractId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.RecipientUser)
.WithMany()
.HasForeignKey(fk => fk.Recipient)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
}
}