Added contract entity
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
namespace PostFundManagement.Domain.Configuration;
|
||||
|
||||
public sealed class Contract : IEntityTypeConfiguration<Entities.Contract>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.Contract> builder)
|
||||
{
|
||||
builder.ToTable(nameof(Entities.Contract).Pluralize());
|
||||
|
||||
builder.HasKey(pk => pk.Id);
|
||||
builder.HasIndex(f => f.AwardId).IsUnique();
|
||||
|
||||
builder.Property(f => f.AwardId).IsRequired();
|
||||
builder.Property(f => f.CreatedBy).IsRequired();
|
||||
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.ExternalSignatureId).IsRequired(false);
|
||||
builder.Property(f => f.SignedDocumentUrl).IsRequired(false);
|
||||
builder.Property(f => f.EffectiveAt).IsRequired(false);
|
||||
builder.Property(f => f.ExpiresAt).IsRequired(false);
|
||||
builder.Property(f => f.TotalValue).IsRequired().HasPrecision(18, 2);
|
||||
builder.Property(f => f.Status).IsRequired().HasDefaultValue(ContractStatus.Draft);
|
||||
|
||||
builder.HasOne(f => f.Award)
|
||||
.WithOne(f => f.Contract)
|
||||
.HasForeignKey<Entities.Contract>(fk => fk.AwardId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(f => f.Creator)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.CreatedBy)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
}
|
||||
}
|
||||
@@ -14,4 +14,6 @@ public class Award : Models.Award
|
||||
public virtual Programme? Programme { get; set; }
|
||||
|
||||
public virtual Project? Project { get; set; }
|
||||
|
||||
public virtual Contract? Contract { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace PostFundManagement.Domain.Entities;
|
||||
|
||||
public class Contract : Models.Contract
|
||||
{
|
||||
public virtual Award? Award { get; set; }
|
||||
|
||||
public virtual User? Creator { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace PostFundManagement.Infrastructure.Database;
|
||||
|
||||
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<Contract> Contracts => Set<Contract>();
|
||||
|
||||
public DbSet<Award> Awards => Set<Award>();
|
||||
|
||||
public DbSet<Project> Projects => Set<Project>();
|
||||
|
||||
Reference in New Issue
Block a user