Added budget entity
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
namespace PostFundManagement.Domain.Configuration;
|
||||
|
||||
public sealed class Budget : IEntityTypeConfiguration<Entities.Budget>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Entities.Budget> builder)
|
||||
{
|
||||
builder.ToTable(nameof(Entities.Budget).Pluralize());
|
||||
|
||||
builder.HasKey(pk => pk.Id);
|
||||
builder.Property(f => f.ProjectId).IsRequired();
|
||||
builder.Property(f => f.CreatedBy).IsRequired();
|
||||
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.Name).IsRequired().HasMaxLength(256);
|
||||
builder.Property(f => f.Amount).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);
|
||||
|
||||
builder.HasOne(f => f.Approver)
|
||||
.WithMany()
|
||||
.HasForeignKey(fk => fk.ApprovedBy)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace PostFundManagement.Domain.Entities;
|
||||
|
||||
public class Budget : Models.Budget
|
||||
{
|
||||
public virtual Project? Project { get; set; }
|
||||
|
||||
public virtual User? Creator { get; set; }
|
||||
|
||||
public virtual User? Approver { get; set; }
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace PostFundManagement.Infrastructure.Database;
|
||||
|
||||
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
||||
{
|
||||
public DbSet<Budget> Budgets => Set<Budget>();
|
||||
|
||||
public DbSet<Contract> Contracts => Set<Contract>();
|
||||
|
||||
public DbSet<Award> Awards => Set<Award>();
|
||||
|
||||
Reference in New Issue
Block a user