feat(dir): point list create endpoint ressult to changes by id endpoint

This commit is contained in:
Collin M. Barrett 2021-11-26 16:54:07 -06:00
parent fec59aaf6d
commit 3eca3ddf9c
3 changed files with 13 additions and 4 deletions

View file

@ -34,10 +34,14 @@ public Task<IActionResult> Get(CancellationToken cancellationToken)
/// <param name="command">The command.</param>
/// <param name="cancellationToken">The cancellation token.</param>
[HttpPost]
[ProducesResponseType(typeof(CreateList.Response), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(CreateList.Response), StatusCodes.Status202Accepted)]
public async Task<IActionResult> Create(CreateList.Command command, CancellationToken cancellationToken)
{
return Ok(await _mediator.Send(command, cancellationToken));
var response = await _mediator.Send(command, cancellationToken);
return AcceptedAtAction(
nameof(ChangesController.GetDetails),
nameof(ChangesController).Replace("Controller", string.Empty),
new { id = response.ChangeId });
}
/// <summary>

View file

@ -26,5 +26,10 @@
app.UseProblemDetails();
app.UseSwagger();
app.MapControllers();
app.Use(async (context, next) =>
{
context.Request.PathBase = "/api/directory";
await next.Invoke();
});
await app.TryRunWithLoggingAsync(() => app.MigrateAsync());

View file

@ -76,9 +76,9 @@ public async Task<Response> Handle(Command request, CancellationToken cancellati
await _commandContext.SaveChangesAsync(cancellationToken);
return new Response();
return new Response(filterList.Changes.Single().Id);
}
}
public record Response { }
public record Response(long ChangeId) { }
}