Added entity-model mappers

Added and applied field size constants
This commit is contained in:
2026-08-16 10:08:33 +02:00
parent f7b30f89ea
commit 109fa0602e
20 changed files with 350 additions and 31 deletions
@@ -0,0 +1,269 @@
using PostFundManagement.Domain.Models;
namespace PostFundManagement.Domain.Extensions;
public static class Mappers
{
public static AuditLog Map(this Entities.AuditLog entity) => new()
{
Id = entity.Id,
Action = entity.Action,
Changes = entity.Changes,
EntityId = entity.EntityId,
EntityName = entity.EntityName,
PerformedBy = entity.PerformedBy,
Timestamp = entity.Timestamp
};
public static Award Map(this Entities.Award entity) => new()
{
Id = entity.Id,
Amount = entity.Amount,
ApprovedBy = entity.ApprovedBy,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
OrganisationId = entity.OrganisationId,
ProgrammeId = entity.ProgrammeId,
ProjectId = entity.ProjectId,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy
};
public static Beneficiary Map(this Entities.Beneficiary entity) => new()
{
Id = entity.Id,
Category = entity.Category,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Location = entity.Location,
Name = entity.Name,
ProjectId = entity.ProjectId,
ReachedCount = entity.ReachedCount,
TargetCount = entity.TargetCount,
UserId = entity.UserId
};
public static Budget Map(this Entities.Budget entity) => new()
{
Id = entity.Id,
Amount = entity.Amount,
ApprovedBy = entity.ApprovedBy,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Name = entity.Name,
ProjectId = entity.ProjectId,
UpdatedAt = entity.UpdatedAt
};
public static ComplianceItem Map(this Entities.ComplianceItem entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
ProjectId = entity.ProjectId,
Requirements = entity.Requirements,
Status = entity.Status,
Title = entity.Title,
UpdatedAt = entity.UpdatedAt,
VerifiedBy = entity.VerifiedBy
};
public static Contract Map(this Entities.Contract entity) => new()
{
Id = entity.Id,
AwardId = entity.AwardId,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
EffectiveAt = entity.EffectiveAt,
ExpiresAt = entity.ExpiresAt,
ExternalSignatureId = entity.ExternalSignatureId,
SignedDocumentUrl = entity.SignedDocumentUrl,
Status = entity.Status,
TotalValue = entity.TotalValue
};
public static Disbursement Map(this Entities.Disbursement entity) => new()
{
Id = entity.Id,
Amount = entity.Amount,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
MilestoneId = entity.MilestoneId,
ProjectId = entity.ProjectId,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy
};
public static Evidence Map(this Entities.Evidence entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
DocumentUrl = entity.DocumentUrl,
IndicatorId = entity.IndicatorId,
MilestoneId = entity.MilestoneId,
ProjectId = entity.ProjectId,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy,
Version = entity.Version
};
public static Indicator Map(this Entities.Indicator entity) => new()
{
Id = entity.Id,
ActualAmount = entity.ActualAmount,
BaselineAmount = entity.BaselineAmount,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Name = entity.Name,
ProjectId = entity.ProjectId,
TargetAmount = entity.TargetAmount,
UnitOfMeasure = entity.UnitOfMeasure
};
public static Instrument Map(this Entities.Instrument entity) => new()
{
Id = entity.Id,
Code = entity.Code,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Description = entity.Description,
Name = entity.Name,
Status = entity.Status
};
public static Issue Map(this Entities.Issue entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Description = entity.Description,
Priority = entity.Priority,
ProjectId = entity.ProjectId,
ResolvedAt = entity.ResolvedAt,
Status = entity.Status,
Title = entity.Title
};
public static Milestone Map(this Entities.Milestone entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
DueAt = entity.DueAt,
Name = entity.Name,
ProjectId = entity.ProjectId,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy
};
public static Organisation Map(this Entities.Organisation entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Email = entity.Email,
Name = entity.Name,
RegistrationNo = entity.RegistrationNo,
Status = entity.Status,
Type = entity.Type
};
public static Outcome Map(this Entities.Outcome entity) => new()
{
Id = entity.Id,
BeneficiaryId = entity.BeneficiaryId,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Description = entity.Description,
Name = entity.Name
};
public static Portfolio Map(this Entities.Portfolio entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Description = entity.Description,
Name = entity.Name,
OwnedBy = entity.OwnedBy
};
public static Programme Map(this Entities.Programme entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
InstrumentId = entity.InstrumentId,
Name = entity.Name,
OwnedBy = entity.OwnedBy,
PortfolioId = entity.PortfolioId,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy
};
public static Project Map(this Entities.Project entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Description = entity.Description,
EndedAt = entity.EndedAt,
Name = entity.Name,
ProgrammeId = entity.ProgrammeId,
StartedAt = entity.StartedAt,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy
};
public static Risk Map(this Entities.Risk entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Description = entity.Description,
Impact = entity.Impact,
Likelihood = entity.Likelihood,
Name = entity.Name,
ProjectId = entity.ProjectId
};
public static Rule Map(this Entities.Rule entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Name = entity.Name,
ProgrammeId = entity.ProgrammeId,
Status = entity.Status,
UpdatedAt = entity.UpdatedAt,
UpdatedBy = entity.UpdatedBy,
Version = entity.Version
};
public static SiteVisit Map(this Entities.SiteVisit entity) => new()
{
Id = entity.Id,
ProjectId = entity.ProjectId,
CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy,
Findings = entity.Findings,
InspectorName = entity.InspectorName,
Status = entity.Status,
VisitedAt = entity.VisitedAt
};
public static User Map(this Entities.User entity) => new()
{
Id = entity.Id,
Email = entity.Email,
LastLoginAt = entity.LastLoginAt,
Status = entity.Status
};
}