From 3eca3ddf9c104cce35baf32ca403695ee1eb7cfa Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Fri, 26 Nov 2021 16:54:07 -0600 Subject: [PATCH] =?UTF-8?q?feat(dir):=20=E2=9C=A8=20point=20list=20create?= =?UTF-8?q?=20endpoint=20ressult=20to=20changes=20by=20id=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ListsController.cs | 8 ++++++-- services/Directory/FilterLists.Directory.Api/Program.cs | 5 +++++ .../Commands/CreateList.cs | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/services/Directory/FilterLists.Directory.Api/Controllers/ListsController.cs b/services/Directory/FilterLists.Directory.Api/Controllers/ListsController.cs index dd5a43845..0b051b456 100644 --- a/services/Directory/FilterLists.Directory.Api/Controllers/ListsController.cs +++ b/services/Directory/FilterLists.Directory.Api/Controllers/ListsController.cs @@ -34,10 +34,14 @@ public Task Get(CancellationToken cancellationToken) /// The command. /// The cancellation token. [HttpPost] - [ProducesResponseType(typeof(CreateList.Response), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(CreateList.Response), StatusCodes.Status202Accepted)] public async Task 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 }); } /// diff --git a/services/Directory/FilterLists.Directory.Api/Program.cs b/services/Directory/FilterLists.Directory.Api/Program.cs index 398c5ea67..8fec9f877 100644 --- a/services/Directory/FilterLists.Directory.Api/Program.cs +++ b/services/Directory/FilterLists.Directory.Api/Program.cs @@ -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()); diff --git a/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs b/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs index 012ee7bc4..91d24edd7 100644 --- a/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs +++ b/services/Directory/FilterLists.Directory.Application/Commands/CreateList.cs @@ -76,9 +76,9 @@ public async Task 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) { } }