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