Added TenantId to mapper methods on all affected models

This commit is contained in:
2026-09-25 08:20:36 +02:00
parent 24697776d0
commit 1efbf9d99f
6 changed files with 44 additions and 23 deletions
@@ -77,7 +77,7 @@ public interface IProjectService
[Log] [Log]
[Audit] [Audit]
Task<Result> UpdateChangeRequestAsync(UpdatehangeRequest request, Guid userId, CancellationToken cancellationToken = default); Task<Result> UpdateChangeRequestAsync(UpdateChangeRequest request, Guid userId, CancellationToken cancellationToken = default);
[Log] [Log]
Task<Result<ChangeRequest[]>> GetChangeRequestsAsync(string projectIdHash, CancellationToken cancellationToken = default); Task<Result<ChangeRequest[]>> GetChangeRequestsAsync(string projectIdHash, CancellationToken cancellationToken = default);
@@ -9,14 +9,14 @@ using PostFundManagement.Infrastructure.Database;
namespace PostFundManagement.Application.Services.Communications; namespace PostFundManagement.Application.Services.Communications;
public sealed class CommunicationsService(IDbContextFactory<ApplicationDbContext> contextFactory, ITenantContextService tenantContext) : ICommunicationsService public sealed class CommunicationsService(IDbContextFactory<ApplicationDbContext> contextFactory, ITenantContextService tenantContext) : ICommunicationsService
{ {
public async Task<Result<Invite>> SendInviteAsync(InviteRequest request, Guid userId, CancellationToken cancellationToken = default) => public async Task<Result<Invite>> SendInviteAsync(InviteRequest request, Guid userId, CancellationToken cancellationToken = default) =>
await Result.Try((Func<Task<Result<Invite>>>)(async () => await Result.Try((Func<Task<Result<Invite>>>)(async () =>
{ {
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken); await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
var invite = new Domain.Entities.Invite var invite = new Domain.Entities.Invite
{ {
OrganisationId = request.OrganisationId, OrganisationId = request.OrganisationId,
InvitedOrganisationId = request.InvitedOrganisationId, InvitedOrganisationId = request.InvitedOrganisationId,
AwardId = request.AwardId, AwardId = request.AwardId,
@@ -82,23 +82,27 @@ public sealed class CommunicationsService(IDbContextFactory<ApplicationDbContext
return Result.Ok(invites.Select(i => i.Map()).ToArray()); return Result.Ok(invites.Select(i => i.Map()).ToArray());
})); }));
public Task<Result> CreateNotificationAsync(CreateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) public async Task<Result> CreateNotificationAsync(CreateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) =>
{ await Result.Try((Func<Task<Result>>)(async () =>
throw new NotImplementedException(); {
} await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
}));
public Task<Result> UpdateNotificationAsync(UpdateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) public async Task<Result> UpdateNotificationAsync(UpdateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) =>
{ await Result.Try((Func<Task<Result>>)(async () =>
throw new NotImplementedException(); {
} await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
}));
public Task<Result<Notification[]>> GetNotificationsAsync(string organisationIdHash, CancellationToken cancellationToken = default) public async Task<Result<Notification[]>> GetNotificationsAsync(string organisationIdHash, CancellationToken cancellationToken = default) =>
{ await Result.Try((Func<Task<Result<Notification[]>>>)(async () =>
throw new NotImplementedException(); {
} await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
}));
public Task<Result<Notification>> GetNotificationAsync(string notificationIdHash, CancellationToken cancellationToken = default) public async Task<Result<Notification>> GetNotificationAsync(string notificationIdHash, CancellationToken cancellationToken = default) =>
{ await Result.Try((Func<Task<Result<Notification>>>)(async () =>
throw new NotImplementedException(); {
} await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
}));
} }
@@ -617,7 +617,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach
public async Task<Result> UpdateBeneficiaryItemAsync(UpdateBeneficiaryRequest request, Guid userId, CancellationToken cancellationToken = default) => public async Task<Result> UpdateBeneficiaryItemAsync(UpdateBeneficiaryRequest request, Guid userId, CancellationToken cancellationToken = default) =>
await service.UpdateBeneficiaryItemAsync(request, userId, cancellationToken); await service.UpdateBeneficiaryItemAsync(request, userId, cancellationToken);
public async Task<Result> UpdateChangeRequestAsync(UpdatehangeRequest request, Guid userId, CancellationToken cancellationToken = default) => public async Task<Result> UpdateChangeRequestAsync(UpdateChangeRequest request, Guid userId, CancellationToken cancellationToken = default) =>
await service.UpdateChangeRequestAsync(request, userId, cancellationToken); await service.UpdateChangeRequestAsync(request, userId, cancellationToken);
public async Task<Result> UpdateComplianceItemAsync(UpdateComplianceItemRequest request, Guid userId, CancellationToken cancellationToken = default) => public async Task<Result> UpdateComplianceItemAsync(UpdateComplianceItemRequest request, Guid userId, CancellationToken cancellationToken = default) =>
@@ -388,7 +388,7 @@ public sealed class ProjectService(IDbContextFactory<ApplicationDbContext> conte
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<Result> UpdateChangeRequestAsync(UpdatehangeRequest request, Guid userId, CancellationToken cancellationToken = default) public Task<Result> UpdateChangeRequestAsync(UpdateChangeRequest request, Guid userId, CancellationToken cancellationToken = default)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -60,7 +60,7 @@ public sealed record CreateComplianceItemRequest([Required] long ProjectId,
[Required][MaxLength(LabelLength)] string Title, [Required][MaxLength(LabelLength)] string Title,
[Required][MaxLength(TextLength)] string Requirements); [Required][MaxLength(TextLength)] string Requirements);
public sealed record UpdatehangeRequest([Required] long ChangeRequestId, public sealed record UpdateChangeRequest([Required] long ChangeRequestId,
[Required][MaxLength(LabelLength)] string Title, [Required][MaxLength(LabelLength)] string Title,
[Required][MaxLength(TextLength)] string Justification, [Required][MaxLength(TextLength)] string Justification,
[Required] decimal RevisedBudget, [Required] decimal RevisedBudget,
@@ -38,6 +38,7 @@ public static class Mappers
public static Activity Map(this Entities.Activity entity) => new() public static Activity Map(this Entities.Activity entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
Amount = entity.Amount, Amount = entity.Amount,
ApprovedBy = entity.ApprovedBy, ApprovedBy = entity.ApprovedBy,
Category = entity.Category, Category = entity.Category,
@@ -56,6 +57,7 @@ public static class Mappers
public static AuditLog Map(this Entities.AuditLog entity) => new() public static AuditLog Map(this Entities.AuditLog entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
Action = entity.Action, Action = entity.Action,
Changes = entity.Changes, Changes = entity.Changes,
EntityId = entity.EntityId, EntityId = entity.EntityId,
@@ -83,6 +85,7 @@ public static class Mappers
public static Beneficiary Map(this Entities.Beneficiary entity) => new() public static Beneficiary Map(this Entities.Beneficiary entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
Category = entity.Category, Category = entity.Category,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
@@ -97,6 +100,7 @@ public static class Mappers
public static Budget Map(this Entities.Budget entity) => new() public static Budget Map(this Entities.Budget entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
Amount = entity.Amount, Amount = entity.Amount,
ApprovedBy = entity.ApprovedBy, ApprovedBy = entity.ApprovedBy,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
@@ -109,6 +113,7 @@ public static class Mappers
public static ComplianceItem Map(this Entities.ComplianceItem entity) => new() public static ComplianceItem Map(this Entities.ComplianceItem entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
ProjectId = entity.ProjectId, ProjectId = entity.ProjectId,
@@ -122,6 +127,7 @@ public static class Mappers
public static Contract Map(this Entities.Contract entity) => new() public static Contract Map(this Entities.Contract entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
AwardId = entity.AwardId, AwardId = entity.AwardId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
@@ -136,6 +142,7 @@ public static class Mappers
public static Disbursement Map(this Entities.Disbursement entity) => new() public static Disbursement Map(this Entities.Disbursement entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
Amount = entity.Amount, Amount = entity.Amount,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
@@ -149,6 +156,7 @@ public static class Mappers
public static Evidence Map(this Entities.Evidence entity) => new() public static Evidence Map(this Entities.Evidence entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
DocumentUrl = entity.DocumentUrl, DocumentUrl = entity.DocumentUrl,
@@ -166,6 +174,7 @@ public static class Mappers
public static Indicator Map(this Entities.Indicator entity) => new() public static Indicator Map(this Entities.Indicator entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
ActualAmount = entity.ActualAmount, ActualAmount = entity.ActualAmount,
BaselineAmount = entity.BaselineAmount, BaselineAmount = entity.BaselineAmount,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
@@ -180,6 +189,7 @@ public static class Mappers
{ {
Id = entity.Id, Id = entity.Id,
Code = entity.Code, Code = entity.Code,
TenantId = entity.TenantId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
Description = entity.Description, Description = entity.Description,
@@ -191,6 +201,7 @@ public static class Mappers
public static Invite Map(this Entities.Invite entity) => new() public static Invite Map(this Entities.Invite entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
AwardId = entity.AwardId, AwardId = entity.AwardId,
ContractId = entity.ContractId, ContractId = entity.ContractId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
@@ -205,6 +216,7 @@ public static class Mappers
public static Issue Map(this Entities.Issue entity) => new() public static Issue Map(this Entities.Issue entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
Description = entity.Description, Description = entity.Description,
@@ -220,6 +232,7 @@ public static class Mappers
public static Milestone Map(this Entities.Milestone entity) => new() public static Milestone Map(this Entities.Milestone entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
DueAt = entity.DueAt, DueAt = entity.DueAt,
@@ -233,7 +246,7 @@ public static class Mappers
public static Organisation Map(this Entities.Organisation entity) => new() public static Organisation Map(this Entities.Organisation entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
Email = entity.Email, Email = entity.Email,
@@ -246,6 +259,7 @@ public static class Mappers
public static Outcome Map(this Entities.Outcome entity) => new() public static Outcome Map(this Entities.Outcome entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
BeneficiaryId = entity.BeneficiaryId, BeneficiaryId = entity.BeneficiaryId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
@@ -317,6 +331,7 @@ public static class Mappers
public static Risk Map(this Entities.Risk entity) => new() public static Risk Map(this Entities.Risk entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
Description = entity.Description, Description = entity.Description,
@@ -329,6 +344,7 @@ public static class Mappers
public static Rule Map(this Entities.Rule entity) => new() public static Rule Map(this Entities.Rule entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,
Name = entity.Name, Name = entity.Name,
@@ -342,6 +358,7 @@ public static class Mappers
public static SiteVisit Map(this Entities.SiteVisit entity) => new() public static SiteVisit Map(this Entities.SiteVisit entity) => new()
{ {
Id = entity.Id, Id = entity.Id,
TenantId = entity.TenantId,
ProjectId = entity.ProjectId, ProjectId = entity.ProjectId,
CreatedAt = entity.CreatedAt, CreatedAt = entity.CreatedAt,
CreatedBy = entity.CreatedBy, CreatedBy = entity.CreatedBy,