Added linkage to primary tenant entities #89
@@ -1,5 +1,6 @@
|
|||||||
using PostFundManagement.Application.Abstractions.Services;
|
using PostFundManagement.Application.Abstractions.Services;
|
||||||
using PostFundManagement.Domain;
|
using PostFundManagement.Domain;
|
||||||
|
using PostFundManagement.Domain.Abstractions;
|
||||||
using PostFundManagement.Domain.Errors;
|
using PostFundManagement.Domain.Errors;
|
||||||
using PostFundManagement.Domain.Extensions;
|
using PostFundManagement.Domain.Extensions;
|
||||||
using PostFundManagement.Domain.Models;
|
using PostFundManagement.Domain.Models;
|
||||||
@@ -7,7 +8,7 @@ using PostFundManagement.Infrastructure.Database;
|
|||||||
|
|
||||||
namespace PostFundManagement.Application.Services.Communications;
|
namespace PostFundManagement.Application.Services.Communications;
|
||||||
|
|
||||||
public sealed class CommunicationsService(IDbContextFactory<ApplicationDbContext> contextFactory) : 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 () =>
|
||||||
@@ -35,7 +36,8 @@ public sealed class CommunicationsService(IDbContextFactory<ApplicationDbContext
|
|||||||
Status = NotificationStatus.Pending,
|
Status = NotificationStatus.Pending,
|
||||||
Subject = "Invitation to Onboard",
|
Subject = "Invitation to Onboard",
|
||||||
Message = request.Message,
|
Message = request.Message,
|
||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
TenantId = tenantContext.TenantId
|
||||||
});
|
});
|
||||||
|
|
||||||
return Result.FailIf(await context.SaveChangesAsync(cancellationToken) <= 0, CreateError.New)
|
return Result.FailIf(await context.SaveChangesAsync(cancellationToken) <= 0, CreateError.New)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using PostFundManagement.Application.Extensions;
|
using PostFundManagement.Application.Extensions;
|
||||||
using PostFundManagement.Application.Services.Shared;
|
using PostFundManagement.Application.Services.Shared;
|
||||||
using PostFundManagement.Domain;
|
using PostFundManagement.Domain;
|
||||||
|
using PostFundManagement.Domain.Abstractions;
|
||||||
using PostFundManagement.Domain.Errors;
|
using PostFundManagement.Domain.Errors;
|
||||||
using PostFundManagement.Domain.Extensions;
|
using PostFundManagement.Domain.Extensions;
|
||||||
using PostFundManagement.Domain.Models;
|
using PostFundManagement.Domain.Models;
|
||||||
@@ -9,7 +10,8 @@ using PostFundManagement.Infrastructure.Database;
|
|||||||
|
|
||||||
namespace PostFundManagement.Application.Services.Governance;
|
namespace PostFundManagement.Application.Services.Governance;
|
||||||
|
|
||||||
public sealed class GovernanceService(IDbContextFactory<ApplicationDbContext> contextFactory, HashService hashService) : IGovernanceService
|
public sealed class GovernanceService(IDbContextFactory<ApplicationDbContext> contextFactory, HashService hashService,
|
||||||
|
ITenantContextService tenantContext) : IGovernanceService
|
||||||
{
|
{
|
||||||
public async Task<Result<Programme[]>> GetProgrammesAsync(string portfolioIdHash, CancellationToken cancellationToken = default) =>
|
public async Task<Result<Programme[]>> GetProgrammesAsync(string portfolioIdHash, CancellationToken cancellationToken = default) =>
|
||||||
await Result.Try((Func<Task<Result<Programme[]>>>)(async () =>
|
await Result.Try((Func<Task<Result<Programme[]>>>)(async () =>
|
||||||
@@ -189,7 +191,8 @@ public sealed class GovernanceService(IDbContextFactory<ApplicationDbContext> co
|
|||||||
OrganisationId = request.OrganisationId,
|
OrganisationId = request.OrganisationId,
|
||||||
OwnedBy = request.OwnerId,
|
OwnedBy = request.OwnerId,
|
||||||
Name = name,
|
Name = name,
|
||||||
Description = request.Description.Humanize(LetterCasing.Sentence).Trim()
|
Description = request.Description.Humanize(LetterCasing.Sentence).Trim(),
|
||||||
|
TenantId = tenantContext.TenantId
|
||||||
});
|
});
|
||||||
|
|
||||||
return Result.OkIf(await context.SaveChangesAsync(cancellationToken) > 0, CreateError.New);
|
return Result.OkIf(await context.SaveChangesAsync(cancellationToken) > 0, CreateError.New);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using PostFundManagement.Infrastructure.Database;
|
|||||||
namespace PostFundManagement.Application.Services.Grants;
|
namespace PostFundManagement.Application.Services.Grants;
|
||||||
|
|
||||||
public sealed class GrantsService(IDbContextFactory<ApplicationDbContext> contextFactory, HashService hashService,
|
public sealed class GrantsService(IDbContextFactory<ApplicationDbContext> contextFactory, HashService hashService,
|
||||||
[FromKeyedServices(Constants.GeneralBucketName)] IS3Service s3Service) : IGrantsService
|
[FromKeyedServices(Constants.GeneralBucketName)] IS3Service s3Service, ITenantContextService tenantContext) : IGrantsService
|
||||||
{
|
{
|
||||||
public async Task<Result<Contract[]>> GetContractsAsync(Pagination pagination, CancellationToken cancellationToken = default) =>
|
public async Task<Result<Contract[]>> GetContractsAsync(Pagination pagination, CancellationToken cancellationToken = default) =>
|
||||||
await Result.Try((Func<Task<Result<Contract[]>>>)(async () =>
|
await Result.Try((Func<Task<Result<Contract[]>>>)(async () =>
|
||||||
@@ -196,7 +196,8 @@ public sealed class GrantsService(IDbContextFactory<ApplicationDbContext> contex
|
|||||||
Amount = request.Amount,
|
Amount = request.Amount,
|
||||||
Status = ApprovalStatus.Pending,
|
Status = ApprovalStatus.Pending,
|
||||||
CreatedBy = userId,
|
CreatedBy = userId,
|
||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
TenantId = tenantContext.TenantId
|
||||||
};
|
};
|
||||||
|
|
||||||
context.Awards.Add(award);
|
context.Awards.Add(award);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using PostFundManagement.Application.Abstractions.Services;
|
using PostFundManagement.Application.Abstractions.Services;
|
||||||
using PostFundManagement.Application.Services.Shared;
|
using PostFundManagement.Application.Services.Shared;
|
||||||
using PostFundManagement.Domain;
|
using PostFundManagement.Domain;
|
||||||
|
using PostFundManagement.Domain.Abstractions;
|
||||||
using PostFundManagement.Domain.Errors;
|
using PostFundManagement.Domain.Errors;
|
||||||
using PostFundManagement.Domain.Extensions;
|
using PostFundManagement.Domain.Extensions;
|
||||||
using PostFundManagement.Domain.Models;
|
using PostFundManagement.Domain.Models;
|
||||||
@@ -8,7 +9,8 @@ using PostFundManagement.Infrastructure.Database;
|
|||||||
|
|
||||||
namespace PostFundManagement.Application.Services.Projects;
|
namespace PostFundManagement.Application.Services.Projects;
|
||||||
|
|
||||||
public sealed class ProjectService(IDbContextFactory<ApplicationDbContext> contextFactory, HashService hashService) : IProjectService
|
public sealed class ProjectService(IDbContextFactory<ApplicationDbContext> contextFactory, HashService hashService,
|
||||||
|
ITenantContextService tenantContext) : IProjectService
|
||||||
{
|
{
|
||||||
public async Task<Result> UpdateProjectStatusAsync(UpdateProjectStatusRequest request, Guid userId, CancellationToken cancellationToken = default) =>
|
public async Task<Result> UpdateProjectStatusAsync(UpdateProjectStatusRequest request, Guid userId, CancellationToken cancellationToken = default) =>
|
||||||
await Result.Try((Func<Task<Result>>)(async () =>
|
await Result.Try((Func<Task<Result>>)(async () =>
|
||||||
@@ -101,7 +103,8 @@ public sealed class ProjectService(IDbContextFactory<ApplicationDbContext> conte
|
|||||||
ProjectType = request.ProjectType,
|
ProjectType = request.ProjectType,
|
||||||
Status = ApprovalStatus.Pending,
|
Status = ApprovalStatus.Pending,
|
||||||
CreatedBy = userId,
|
CreatedBy = userId,
|
||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
TenantId = tenantContext.TenantId
|
||||||
});
|
});
|
||||||
|
|
||||||
return Result.OkIf(await context.SaveChangesAsync(cancellationToken) > 0,
|
return Result.OkIf(await context.SaveChangesAsync(cancellationToken) > 0,
|
||||||
@@ -303,7 +306,8 @@ public sealed class ProjectService(IDbContextFactory<ApplicationDbContext> conte
|
|||||||
Name = name,
|
Name = name,
|
||||||
CreatedBy = userId,
|
CreatedBy = userId,
|
||||||
CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
Status = ApprovalStatus.Pending
|
Status = ApprovalStatus.Pending,
|
||||||
|
TenantId = tenantContext.TenantId
|
||||||
});
|
});
|
||||||
|
|
||||||
return Result.OkIf(await context.SaveChangesAsync(cancellationToken) > 0, CreateError.New);
|
return Result.OkIf(await context.SaveChangesAsync(cancellationToken) > 0, CreateError.New);
|
||||||
|
|||||||
Reference in New Issue
Block a user