Compose coherent Overview snapshots and preserve access ordering
This commit is contained in:
1 parent
cab10c5306
commit
cc7f87105d
16 files changed
+38314
-5
No files matched your search
@@ -0,0 +1,17 @@
|
||||
using HealthApp.Contracts;
|
||||
using HealthApp.Infrastructure;
|
||||
using HealthApp.Security;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
namespace HealthApp.Controllers;
|
||||
[ApiController]
|
||||
public sealed class HealthOverviewController(OverviewQueries overview,AccessPolicy access,RequestTransaction tx) : ControllerBase
|
||||
{
|
||||
[HttpGet("api/patients/{patientId:guid}/overview")]
|
||||
public async Task<IActionResult> Get(Guid patientId,[FromQuery,BindRequired]DateTime from,[FromQuery,BindRequired]DateTime to,[FromQuery]ContextSelection selection,CancellationToken ct)
|
||||
{
|
||||
var scope=await access.AuthorizeAsync(User,patientId,false,ct);if(scope is null){Response.StatusCode=404;return new EmptyResult();}
|
||||
try{var o=await overview.GetAsync(scope,from,to,selection,ct);await tx.FinishAsync(ct);return o is null?Problem(statusCode:404,title:"Patient does not exist."):Ok(o);}
|
||||
catch(ArgumentException){ModelState.AddModelError(nameof(to),"The end time must not be earlier than the start time.");return ValidationProblem(ModelState);}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user