Added project entity
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
namespace PostFundManagement.Domain.Configuration;
|
||||
|
||||
public sealed class Project : IEntityTypeConfiguration<Entities.Project>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.Project> builder)
|
||||
{
|
||||
builder.ToTable(nameof(Entities.Project).Pluralize());
|
||||
|
||||
builder.HasKey(pk => pk.Id);
|
||||
builder.Property(f => f.ProgrammeId).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.Property(f => f.StartedAt).IsRequired(false);
|
||||
builder.Property(f => f.EndedAt).IsRequired(false);
|
||||
builder.Property(f => f.Name).IsRequired().HasMaxLength(256);
|
||||
builder.Property(f => f.Description).IsRequired().HasMaxLength(1024);
|
||||
builder.Property(f => f.StartedAt).IsRequired().HasDefaultValue(ApprovalStatus.Pending);
|
||||
|
||||
builder.HasOne(f => f.Programme)
|
||||
.WithMany(f => f.Projects)
|
||||
.HasForeignKey(fk => fk.ProgrammeId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,6 @@ public class Programme : Models.Programme
|
||||
public virtual Instrument? Instrument { get; set; }
|
||||
|
||||
public virtual ICollection<Rule> Rules { get; set; } = [];
|
||||
|
||||
public virtual ICollection<Project> Projects { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace PostFundManagement.Domain.Entities;
|
||||
|
||||
[EntityTypeConfiguration<Configuration.Project, Project>]
|
||||
public class Project : Models.Project
|
||||
{
|
||||
public virtual User? Creator { get; set; }
|
||||
|
||||
public virtual User? Updator { get; set; }
|
||||
|
||||
public virtual Programme? Programme { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace PostFundManagement.Infrastructure.Database;
|
||||
|
||||
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<Project> Projects => Set<Project>();
|
||||
|
||||
public DbSet<Organisation> Organisations => Set<Organisation>();
|
||||
|
||||
public DbSet<Rule> Rules => Set<Rule>();
|
||||
|
||||
Reference in New Issue
Block a user