Added missing endpoints

This commit is contained in:
2026-09-01 12:29:00 +02:00
parent 2df5b5c2ed
commit b8aa5651fa
9 changed files with 105 additions and 10 deletions
@@ -44,7 +44,7 @@ public sealed class GovernanceService(IDbContextFactory<ApplicationDbContext> co
return Result.Ok(organisations.Select(o => o.Map()).ToArray());
}));
public async ValueTask<Result<Organisation>> GetOrganisationByIdAsync(string organisationIdHash, CancellationToken cancellationToken = default) =>
public async ValueTask<Result<Organisation>> GetOrganisationAsync(string organisationIdHash, CancellationToken cancellationToken = default) =>
await Result.Try((Func<ValueTask<Result<Organisation>>>)(async () =>
{
var decodeResult = hashService.DecodeLongIdHash(organisationIdHash);
@@ -120,4 +120,20 @@ public sealed class GovernanceService(IDbContextFactory<ApplicationDbContext> co
return Result.FailIf(await context.SaveChangesAsync(cancellationToken) <= 0, CreateError.New);
}));
public async ValueTask<Result<Organisation>> UpdateOrganisationAsync(UpdateOrganisationRequest request, CancellationToken cancellationToken = default) =>
await Result.Try((Func<ValueTask<Result<Organisation>>>)(async () =>
{
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
var changedTotal = await context.Organisations
.Where(f => f.Id == request.OrganisationId)
.ExecuteUpdateAsync(f => f
.SetProperty(u => u.Name, request.Name)
.SetProperty(u => u.RegistrationNo, request.RegistrationNo)
.SetProperty(u => u.Email, request.Email)
.SetProperty(u => u.Type, request.Type), cancellationToken);
return Result.FailIf(changedTotal <= 0, UpdateError.New);
}));
}