Added indicator entity
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
namespace PostFundManagement.Domain.Configuration;
|
||||
|
||||
public sealed class Indicator : IEntityTypeConfiguration<Entities.Indicator>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.Indicator> builder)
|
||||
{
|
||||
builder.ToTable(nameof(Entities.Indicator).Pluralize());
|
||||
|
||||
builder.HasKey(pk => pk.Id);
|
||||
builder.Property(f => f.ProjectId).IsRequired();
|
||||
builder.Property(f => f.CreatedBy).IsRequired();
|
||||
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.Name).IsRequired().HasMaxLength(256);
|
||||
builder.Property(f => f.UnitOfMeasure).IsRequired().HasDefaultValue(UnitOfMeasure.Percentage);
|
||||
builder.Property(f => f.BaselineAmount).IsRequired().HasPrecision(18, 2);
|
||||
builder.Property(f => f.TargetAmount).IsRequired().HasPrecision(18, 2);
|
||||
builder.Property(f => f.ActualAmount).IsRequired().HasPrecision(18, 2);
|
||||
|
||||
builder.HasOne(f => f.Project)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.ProjectId)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(f => f.Creator)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.CreatedBy)
|
||||
.IsRequired()
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace PostFundManagement.Domain.Entities;
|
||||
|
||||
[EntityTypeConfiguration<Configuration.Indicator, Indicator>]
|
||||
public class Indicator : Models.Indicator
|
||||
{
|
||||
public virtual Project? Project { 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<Indicator> Indicators => Set<Indicator>();
|
||||
|
||||
public DbSet<Disbursement> Disbursements => Set<Disbursement>();
|
||||
|
||||
public DbSet<Milestone> Milestones => Set<Milestone>();
|
||||
|
||||
Reference in New Issue
Block a user