diff --git a/PostFundManagement.Application/Abstractions/Services/IProjectService.cs b/PostFundManagement.Application/Abstractions/Services/IProjectService.cs index 1883fb5..023f172 100644 --- a/PostFundManagement.Application/Abstractions/Services/IProjectService.cs +++ b/PostFundManagement.Application/Abstractions/Services/IProjectService.cs @@ -77,7 +77,7 @@ public interface IProjectService [Log] [Audit] - Task UpdateChangeRequestAsync(UpdatehangeRequest request, Guid userId, CancellationToken cancellationToken = default); + Task UpdateChangeRequestAsync(UpdateChangeRequest request, Guid userId, CancellationToken cancellationToken = default); [Log] Task> GetChangeRequestsAsync(string projectIdHash, CancellationToken cancellationToken = default); diff --git a/PostFundManagement.Application/Services/Communications/CommunicationsService.cs b/PostFundManagement.Application/Services/Communications/CommunicationsService.cs index 824d5ff..712583e 100644 --- a/PostFundManagement.Application/Services/Communications/CommunicationsService.cs +++ b/PostFundManagement.Application/Services/Communications/CommunicationsService.cs @@ -9,14 +9,14 @@ using PostFundManagement.Infrastructure.Database; namespace PostFundManagement.Application.Services.Communications; public sealed class CommunicationsService(IDbContextFactory contextFactory, ITenantContextService tenantContext) : ICommunicationsService -{ +{ public async Task> SendInviteAsync(InviteRequest request, Guid userId, CancellationToken cancellationToken = default) => await Result.Try((Func>>)(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 i.Map()).ToArray()); })); - public Task CreateNotificationAsync(CreateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) - { - throw new NotImplementedException(); - } + public async Task CreateNotificationAsync(CreateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) => + await Result.Try((Func>)(async () => + { + await using var context = await contextFactory.CreateDbContextAsync(cancellationToken); + })); - public Task UpdateNotificationAsync(UpdateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) - { - throw new NotImplementedException(); - } + public async Task UpdateNotificationAsync(UpdateNotificationRequest request, Guid userId, CancellationToken cancellationToken = default) => + await Result.Try((Func>)(async () => + { + await using var context = await contextFactory.CreateDbContextAsync(cancellationToken); + })); - public Task> GetNotificationsAsync(string organisationIdHash, CancellationToken cancellationToken = default) - { - throw new NotImplementedException(); - } + public async Task> GetNotificationsAsync(string organisationIdHash, CancellationToken cancellationToken = default) => + await Result.Try((Func>>)(async () => + { + await using var context = await contextFactory.CreateDbContextAsync(cancellationToken); + })); - public Task> GetNotificationAsync(string notificationIdHash, CancellationToken cancellationToken = default) - { - throw new NotImplementedException(); - } + public async Task> GetNotificationAsync(string notificationIdHash, CancellationToken cancellationToken = default) => + await Result.Try((Func>>)(async () => + { + await using var context = await contextFactory.CreateDbContextAsync(cancellationToken); + })); } diff --git a/PostFundManagement.Application/Services/Projects/ProjectCacheService.cs b/PostFundManagement.Application/Services/Projects/ProjectCacheService.cs index d927741..0660080 100644 --- a/PostFundManagement.Application/Services/Projects/ProjectCacheService.cs +++ b/PostFundManagement.Application/Services/Projects/ProjectCacheService.cs @@ -617,7 +617,7 @@ public sealed class ProjectCacheService(ProjectService service, IDistributedCach public async Task UpdateBeneficiaryItemAsync(UpdateBeneficiaryRequest request, Guid userId, CancellationToken cancellationToken = default) => await service.UpdateBeneficiaryItemAsync(request, userId, cancellationToken); - public async Task UpdateChangeRequestAsync(UpdatehangeRequest request, Guid userId, CancellationToken cancellationToken = default) => + public async Task UpdateChangeRequestAsync(UpdateChangeRequest request, Guid userId, CancellationToken cancellationToken = default) => await service.UpdateChangeRequestAsync(request, userId, cancellationToken); public async Task UpdateComplianceItemAsync(UpdateComplianceItemRequest request, Guid userId, CancellationToken cancellationToken = default) => diff --git a/PostFundManagement.Application/Services/Projects/ProjectService.cs b/PostFundManagement.Application/Services/Projects/ProjectService.cs index d2abeb5..0d615f8 100644 --- a/PostFundManagement.Application/Services/Projects/ProjectService.cs +++ b/PostFundManagement.Application/Services/Projects/ProjectService.cs @@ -388,7 +388,7 @@ public sealed class ProjectService(IDbContextFactory conte throw new NotImplementedException(); } - public Task UpdateChangeRequestAsync(UpdatehangeRequest request, Guid userId, CancellationToken cancellationToken = default) + public Task UpdateChangeRequestAsync(UpdateChangeRequest request, Guid userId, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } diff --git a/PostFundManagement.Application/Services/Projects/Records.cs b/PostFundManagement.Application/Services/Projects/Records.cs index 5934724..17fba04 100644 --- a/PostFundManagement.Application/Services/Projects/Records.cs +++ b/PostFundManagement.Application/Services/Projects/Records.cs @@ -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, diff --git a/PostFundManagement.Domain/Extensions/Mappers.cs b/PostFundManagement.Domain/Extensions/Mappers.cs index 0355088..a49bbbe 100644 --- a/PostFundManagement.Domain/Extensions/Mappers.cs +++ b/PostFundManagement.Domain/Extensions/Mappers.cs @@ -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,