Added budget update
Added portfolio and programme value calculator endpoints
This commit is contained in:
@@ -167,7 +167,8 @@ public sealed class GrantsService(IDbContextFactory<ApplicationDbContext> contex
|
||||
Name = request.Name,
|
||||
Amount = request.Amount,
|
||||
CreatedBy = userId,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
Status = ApprovalStatus.Pending
|
||||
};
|
||||
|
||||
context.Budgets.Add(budget);
|
||||
@@ -273,4 +274,19 @@ public sealed class GrantsService(IDbContextFactory<ApplicationDbContext> contex
|
||||
|
||||
return Result.OkIf(changedTotal > 0, UpdateError.Create("Failed to update the contract."));
|
||||
}));
|
||||
|
||||
public async Task<Result> UpdateBudgetAsync(UpdateBudgetRequest request, Guid userId, CancellationToken cancellationToken = default) =>
|
||||
await Result.Try((Func<Task<Result>>)(async () =>
|
||||
{
|
||||
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
var changedTotal = await context.Budgets
|
||||
.Where(f => f.Id == request.BudgetId)
|
||||
.ExecuteUpdateAsync(f => f
|
||||
.SetProperty(u => u.ApprovedBy, userId)
|
||||
.SetProperty(u => u.UpdatedAt, DateTime.UtcNow)
|
||||
.SetProperty(u => u.Status, request.Status), cancellationToken);
|
||||
|
||||
return Result.OkIf(changedTotal > 0, UpdateError.Create("Failed to update budget"));
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user