Implemented models

This commit is contained in:
2026-08-15 15:06:08 +02:00
parent cd7eb15cc4
commit a5689dd8fc
37 changed files with 729 additions and 12 deletions
-6
View File
@@ -1,6 +0,0 @@
namespace PostFundManagement.Domain;
public class Class1
{
}
@@ -0,0 +1,22 @@
namespace PostFundManagement.Domain.Configuration;
public sealed class Instrument : IEntityTypeConfiguration<Entities.Instrument>
{
public void Configure(EntityTypeBuilder<Entities.Instrument> builder)
{
builder.ToTable(nameof(Entities.Instrument).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.Code).IsRequired().HasMaxLength(50);
builder.Property(f => f.Name).IsRequired().HasMaxLength(256);
builder.Property(f => f.Description).IsRequired(false).HasMaxLength(1024);
builder.Property(f => f.Status).IsRequired().HasDefaultValue(ActivityStatus.Inactive);
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(f => f.CreatedBy)
.OnDelete(DeleteBehavior.NoAction);
}
}
@@ -0,0 +1,27 @@
namespace PostFundManagement.Domain.Configuration;
public sealed class Portfolio : IEntityTypeConfiguration<Entities.Portfolio>
{
public void Configure(EntityTypeBuilder<Entities.Portfolio> builder)
{
builder.ToTable(nameof(Entities.Portfolio).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.OwnedBy).IsRequired(false);
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.Name).IsRequired().HasMaxLength(256);
builder.Property(f => f.Description).IsRequired(false).HasMaxLength(1024);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(f => f.CreatedBy)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Owner)
.WithMany()
.HasForeignKey(f => f.OwnedBy)
.OnDelete(DeleteBehavior.NoAction);
}
}
@@ -0,0 +1,43 @@
namespace PostFundManagement.Domain.Configuration;
public sealed class Programme : IEntityTypeConfiguration<Entities.Programme>
{
public void Configure(EntityTypeBuilder<Entities.Programme> builder)
{
builder.ToTable(nameof(Entities.Programme).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.PortfolioId).IsRequired();
builder.Property(f => f.InstrumentId).IsRequired();
builder.Property(f => f.OwnedBy).IsRequired(false);
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.Name).IsRequired().HasMaxLength(256);
builder.Property(f => f.Status).IsRequired(false).HasDefaultValue(ApprovalStatus.Pending);
builder.HasOne(f => f.Portfolio)
.WithMany(f => f.Programmes)
.HasForeignKey(f => f.PortfolioId)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Instrument)
.WithMany(f => f.Programmes)
.HasForeignKey(f => f.InstrumentId)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(f => f.CreatedBy)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Owner)
.WithMany()
.HasForeignKey(f => f.OwnedBy)
.OnDelete(DeleteBehavior.NoAction);
}
}
@@ -0,0 +1,14 @@
namespace PostFundManagement.Domain.Configuration;
public sealed class User : IEntityTypeConfiguration<Entities.User>
{
public void Configure(EntityTypeBuilder<Entities.User> builder)
{
builder.ToTable(nameof(Entities.User).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.Email).IsRequired().HasMaxLength(256);
builder.Property(f => f.Status).IsRequired().HasDefaultValue(ActivityStatus.Inactive);
builder.Property(f => f.LastLoginAt).IsRequired(false);
}
}
@@ -0,0 +1,9 @@
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<Configuration.Instrument, Instrument>]
public class Instrument : Models.Instrument
{
public virtual User? Creator { get; set; }
public virtual ICollection<Programme> Programmes { get; set; } = [];
}
@@ -0,0 +1,11 @@
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<Configuration.Portfolio, Portfolio>]
public class Portfolio : Models.Portfolio
{
public virtual User? Creator { get; set; }
public virtual User? Owner { get; set; }
public virtual ICollection<Programme> Programmes { get; set; } = [];
}
@@ -0,0 +1,13 @@
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<Configuration.Programme, Programme>]
public class Programme : Models.Programme
{
public virtual User? Creator { get; set; }
public virtual User? Owner { get; set; }
public virtual Portfolio? Portfolio { get; set; }
public virtual Instrument? Instrument { get; set; }
}
@@ -0,0 +1,4 @@
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<Configuration.User, User>]
public sealed class User : Models.User;
+64
View File
@@ -0,0 +1,64 @@
namespace PostFundManagement.Domain;
public enum Priority : int
{
Low = 1,
Medium = 2,
High = 3,
Critical = 4
}
public enum UnitOfMeasure : int
{
Count = 1,
Percentage = 2,
Currency = 3,
Area = 4,
Weight = 5,
Volume = 6,
DurationDays = 7,
DurationMonths = 8,
Ratio = 9
}
public enum ContractStatus : int
{
Draft = 1,
PendingApproval = 2,
Active = 3,
Expired = 4,
Terminated = 5,
Amended = 6
}
public enum RiskLikelihood : int
{
Rare = 1,
Unlikely = 2,
Possible = 3,
Likely = 4,
AlmostCertain = 5
}
public enum RiskImpact : int
{
Negligible = 1,
Minor = 2,
Moderate = 3,
Major = 4,
Critical = 5
}
public enum ApprovalStatus : int
{
Pending = 1,
Review = 2,
Approved = 3,
Rejected = 4
}
public enum ActivityStatus : int
{
Active = 1,
Inactive = 2,
Disabled = 3
}
@@ -0,0 +1,18 @@
namespace PostFundManagement.Domain.Models;
public class AuditLog
{
public long Id { get; set; }
public string? EntityName { get; set; }
public long EntityId { get; set; }
public string? Action { get; set; }
public string[]? Changes { get; set; }
public Guid PerformedBy { get; set; }
public DateTime Timestamp { get; set; }
}
+26
View File
@@ -0,0 +1,26 @@
namespace PostFundManagement.Domain.Models;
public class Award
{
public long Id { get; set; }
public long OrganisationId { get; set; }
public long ProgrammeId { get; set; }
public long? ProjectId { get; set; }
public Guid CreatedBy { get; set; }
public Guid? UpdatedBy { get; set; }
public Guid? ApprovedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public ApprovalStatus Status { get; set; }
public decimal Amount { get; set; }
}
@@ -0,0 +1,24 @@
namespace PostFundManagement.Domain.Models;
public class Beneficiary
{
public long Id { get; set; }
public long ProjectId { get; set; }
public Guid UserId { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public string? Name { get; set; }
public string? Category { get; set; }
public int TargetCount { get; set; }
public int ReachedCount { get; set; }
public string? Location { get; set; }
}
@@ -0,0 +1,20 @@
namespace PostFundManagement.Domain.Models;
public class Budget
{
public long Id { get; set; }
public long ProjectId { get; set; }
public Guid CreatedBy { get; set; }
public Guid? ApprovedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public string? Name { get; set; }
public decimal Amount { get; set; }
}
@@ -0,0 +1,26 @@
namespace PostFundManagement.Domain.Models;
public class ChangeRequest
{
public long Id { get; set; }
public long ProjectId { get; set; }
public string? Title { get; set; }
public string? Justification { get; set; }
public decimal? RevisedBudget { get; set; }
public DateTime? RevisedEndedAt { get; set; }
public ApprovalStatus Status { get; set; }
public Guid CreatedBy { get; set; }
public Guid? ApprovedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}
@@ -0,0 +1,22 @@
namespace PostFundManagement.Domain.Models;
public class ComplianceItem
{
public long Id { get; set; }
public long ProjectId { get; set; }
public string? Title { get; set; }
public string? Requirements { get; set; }
public ApprovalStatus Status { get; set; }
public Guid CreatedBy { get; set; }
public Guid? VerifiedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? VerifiedAt { get; set; }
}
@@ -0,0 +1,24 @@
namespace PostFundManagement.Domain.Models;
public class Contract
{
public long Id { get; set; }
public long AwardId { get; set; }
public string? ExternalSignatureId { get; set; }
public string? SignedDocumentUrl { get; set; }
public DateTime? EffectiveAt { get; set; }
public DateTime? ExpiresAt { get; set; }
public decimal TotalValue { get; set; }
public ContractStatus Status { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
}
@@ -0,0 +1,22 @@
namespace PostFundManagement.Domain.Models;
public class Disbursement
{
public long Id { get; set; }
public long ProjectId { get; set; }
public long? MilestoneId { get; set; }
public Guid CreatedBy { get; set; }
public Guid? UpdatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public decimal Amount { get; set; }
public ApprovalStatus Status { get; set; }
}
@@ -0,0 +1,26 @@
namespace PostFundManagement.Domain.Models;
public class Evidence
{
public long Id { get; set; }
public long ProjectId { get; set; }
public long? MilestoneId { get; set; }
public long? IndicatorId { get; set; }
public Guid CreatedBy { get; set; }
public Guid? UpdatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public int Version { get; set; }
public string? DocumentUrl { get; set; }
public ApprovalStatus Status { get; set; }
}
@@ -0,0 +1,22 @@
namespace PostFundManagement.Domain.Models;
public class Indicator
{
public long Id { get; set; }
public long ProjectId { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public string? Name { get; set; }
public UnitOfMeasure? UnitOfMeasure { get; set; }
public decimal BaselineAmount { get; set; }
public decimal TargetAmount { get; set; }
public decimal ActualAmount { get; set; }
}
@@ -0,0 +1,18 @@
namespace PostFundManagement.Domain.Models;
public class Instrument
{
public long Id { get; set; }
public string? Code { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public ActivityStatus Status { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
}
+22
View File
@@ -0,0 +1,22 @@
namespace PostFundManagement.Domain.Models;
public class Issue
{
public long Id { get; set; }
public long ProjectId { get; set; }
public string? Title { get; set; }
public string? Description { get; set; }
public Priority Priority { get; set; }
public ActivityStatus Status { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? ResolvedAt { get; set; }
}
@@ -0,0 +1,22 @@
namespace PostFundManagement.Domain.Models;
public class Milestone
{
public long Id { get; set; }
public long ProjectId { get; set; }
public Guid CreatedBy { get; set; }
public Guid? UpdatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public DateTime DueAt { get; set; }
public string? Name { get; set; }
public ApprovalStatus Status { get; set; }
}
@@ -0,0 +1,20 @@
namespace PostFundManagement.Domain.Models;
public class Organisation
{
public long Id { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public string? RegistrationNo { get; set; }
public string? Name { get; set; }
public string? Email { get; set; }
public int Type { get; set; }
public ActivityStatus Status { get; set; }
}
@@ -0,0 +1,16 @@
namespace PostFundManagement.Domain.Models;
public class Outcome
{
public long Id { get; set; }
public long BeneficiaryId { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
}
@@ -0,0 +1,16 @@
namespace PostFundManagement.Domain.Models;
public class Portfolio
{
public long Id { get; set; }
public Guid OwnedBy { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
}
@@ -0,0 +1,24 @@
namespace PostFundManagement.Domain.Models;
public class Programme
{
public long Id { get; set; }
public long PortfolioId { get; set; }
public long InstrumentId { get; set; }
public Guid OwnedBy { get; set; }
public Guid CreatedBy { get; set; }
public Guid? UpdatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public string? Name { get; set; }
public ApprovalStatus Status { get; set; }
}
@@ -0,0 +1,26 @@
namespace PostFundManagement.Domain.Models;
public class Project
{
public long Id { get; set; }
public long ProgrammeId { get; set; }
public Guid CreatedBy { get; set; }
public Guid? UpdatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public DateTime? StartedAt { get; set; }
public DateTime? EndedAt { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public ApprovalStatus Status { get; set; }
}
+20
View File
@@ -0,0 +1,20 @@
namespace PostFundManagement.Domain.Models;
public class Risk
{
public long Id { get; set; }
public long ProjectId { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public RiskLikelihood Likelihood { get; set; }
public RiskImpact Impact { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
}
+22
View File
@@ -0,0 +1,22 @@
namespace PostFundManagement.Domain.Models;
public class Rule
{
public long Id { get; set; }
public long ProgrammeId { get; set; }
public Guid CreatedBy { get; set; }
public Guid? UpdatedBy { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public string? Name { get; set; }
public int Version { get; set; }
public ActivityStatus Status { get; set; }
}
@@ -0,0 +1,20 @@
namespace PostFundManagement.Domain.Models;
public class SiteVisit
{
public long Id { get; set; }
public long ProjectId { get; set; }
public DateTime VisitedAt { get; set; }
public string? InspectorName { get; set; }
public string? Findings { get; set; }
public ApprovalStatus VerificationStatus { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedAt { get; set; }
}
+12
View File
@@ -0,0 +1,12 @@
namespace PostFundManagement.Domain.Models;
public class User
{
public Guid Id { get; set; }
public DateTime LastLoginAt { get; set; }
public string? Email { get; set; }
public ActivityStatus Status { get; set; }
}
@@ -6,4 +6,30 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Humanizer" Version="3.0.10" />
<Using Include="Humanizer" />
</ItemGroup>
<!-- Database -->
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="10.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="10.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.11">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.11">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
<Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Builders" />
</ItemGroup>
</Project>
@@ -1,6 +0,0 @@
namespace PostFundManagement.Infrastructure;
public class Class1
{
}
@@ -0,0 +1,12 @@
using PostFundManagement.Domain.Entities;
namespace PostFundManagement.Infrastructure.Database;
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
{
public DbSet<Portfolio> Portfolios => Set<Portfolio>();
public DbSet<Instrument> Instruments => Set<Instrument>();
public DbSet<User> Users => Set<User>();
}
@@ -6,4 +6,12 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Using Include="Microsoft.EntityFrameworkCore" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PostFundManagement.Domain\PostFundManagement.Domain.csproj" />
</ItemGroup>
</Project>
+8
View File
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}