41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
namespace PostFundManagement.Domain.Entities;
|
|
|
|
[EntityTypeConfiguration<OrganisationConfiguration, Organisation>]
|
|
public class Organisation : Models.Organisation
|
|
{
|
|
public virtual User? User { get; set; }
|
|
|
|
public virtual User? Creator { get; set; }
|
|
}
|
|
|
|
public sealed class OrganisationConfiguration : IEntityTypeConfiguration<Organisation>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Organisation> builder)
|
|
{
|
|
builder.ToTable(nameof(Organisation).Pluralize());
|
|
|
|
builder.HasKey(pk => pk.Id);
|
|
builder.Property(f => f.CreatedBy).IsRequired();
|
|
builder.Property(f => f.UserId).IsRequired(false);
|
|
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
|
builder.Property(f => f.RegistrationNo).IsRequired().HasMaxLength(LabelLength);
|
|
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
|
|
builder.Property(f => f.Email).IsRequired().HasMaxLength(LabelLength);
|
|
builder.Property(f => f.Type).IsRequired().HasConversion<int>().HasDefaultValueSql("5")
|
|
.HasSentinel(OrganisationType.PrivateLimitedCompany);
|
|
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1")
|
|
.HasSentinel(ActivityStatus.Active);
|
|
|
|
builder.HasOne(f => f.User)
|
|
.WithMany()
|
|
.HasForeignKey(fk => fk.UserId)
|
|
.IsRequired(false)
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
|
|
builder.HasOne(f => f.Creator)
|
|
.WithMany()
|
|
.HasForeignKey(fk => fk.CreatedBy)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.NoAction);
|
|
}
|
|
} |