Added award entity
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
namespace PostFundManagement.Domain.Configuration;
|
||||||
|
|
||||||
|
public class Award : IEntityTypeConfiguration<Entities.Award>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Entities.Award> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(nameof(Entities.Award).Pluralize());
|
||||||
|
|
||||||
|
builder.HasKey(pk => pk.Id);
|
||||||
|
builder.Property(f => f.OrganisationId).IsRequired();
|
||||||
|
builder.Property(f => f.ProgrammeId).IsRequired();
|
||||||
|
builder.Property(f => f.ProjectId).IsRequired(false);
|
||||||
|
builder.Property(f => f.CreatedBy).IsRequired();
|
||||||
|
builder.Property(f => f.UpdatedBy).IsRequired(false);
|
||||||
|
builder.Property(f => f.ApprovedBy).IsRequired(false);
|
||||||
|
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
||||||
|
builder.Property(f => f.UpdatedAt).IsRequired(false);
|
||||||
|
builder.Property(f => f.Status).IsRequired().HasDefaultValue(ApprovalStatus.Pending);
|
||||||
|
builder.Property(f => f.Amount).IsRequired().HasPrecision(18, 2);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Organisation)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.OrganisationId)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Programme)
|
||||||
|
.WithMany(f => f.Awards)
|
||||||
|
.HasForeignKey(fk => fk.ProgrammeId)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Project)
|
||||||
|
.WithMany(f => f.Awards)
|
||||||
|
.HasForeignKey(fk => fk.ProjectId)
|
||||||
|
.IsRequired(false)
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Creator)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.CreatedBy)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Updator)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.UpdatedBy)
|
||||||
|
.IsRequired(false)
|
||||||
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Approver)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.ApprovedBy)
|
||||||
|
.IsRequired(false)
|
||||||
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace PostFundManagement.Domain.Entities;
|
||||||
|
|
||||||
|
[EntityTypeConfiguration<Configuration.Award, Award>]
|
||||||
|
public class Award : Models.Award
|
||||||
|
{
|
||||||
|
public virtual User? Creator { get; set; }
|
||||||
|
|
||||||
|
public virtual User? Updator { get; set; }
|
||||||
|
|
||||||
|
public virtual User? Approver { get; set; }
|
||||||
|
|
||||||
|
public virtual Organisation? Organisation { get; set; }
|
||||||
|
|
||||||
|
public virtual Programme? Programme { get; set; }
|
||||||
|
|
||||||
|
public virtual Project? Project { get; set; }
|
||||||
|
}
|
||||||
@@ -14,4 +14,6 @@ public class Programme : Models.Programme
|
|||||||
public virtual ICollection<Rule> Rules { get; set; } = [];
|
public virtual ICollection<Rule> Rules { get; set; } = [];
|
||||||
|
|
||||||
public virtual ICollection<Project> Projects { get; set; } = [];
|
public virtual ICollection<Project> Projects { get; set; } = [];
|
||||||
|
|
||||||
|
public virtual ICollection<Award> Awards { get; set; } = [];
|
||||||
}
|
}
|
||||||
@@ -8,4 +8,6 @@ public class Project : Models.Project
|
|||||||
public virtual User? Updator { get; set; }
|
public virtual User? Updator { get; set; }
|
||||||
|
|
||||||
public virtual Programme? Programme { get; set; }
|
public virtual Programme? Programme { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Award> Awards { get; set; } = [];
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,8 @@ namespace PostFundManagement.Infrastructure.Database;
|
|||||||
|
|
||||||
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
|
public DbSet<Award> Awards => Set<Award>();
|
||||||
|
|
||||||
public DbSet<Project> Projects => Set<Project>();
|
public DbSet<Project> Projects => Set<Project>();
|
||||||
|
|
||||||
public DbSet<Organisation> Organisations => Set<Organisation>();
|
public DbSet<Organisation> Organisations => Set<Organisation>();
|
||||||
|
|||||||
Reference in New Issue
Block a user