-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,077 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 10 additions & 12 deletions
22
src/Services/Order.Command/Order.Command.API/Endpoints/DeleteOrder/Endpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
using Order.Command.Application.Orders.Commands.DeleteOrder; | ||
using Order.Command.Domain.Models.ValueObjects; | ||
|
||
namespace Order.Command.API.Endpoints.DeleteOrder; | ||
|
||
public class Endpoint : EndpointBase<Request, Response> | ||
public class Endpoint : EndpointBase<Request> | ||
{ | ||
public override void MapEndpoint() | ||
{ | ||
Delete("/orders/{order_id}", HandleAsync); | ||
Name("DeleteOrder"); | ||
Produces(StatusCodes.Status202Accepted); | ||
Produces(StatusCodes.Status204NoContent); | ||
ProducesProblem(StatusCodes.Status400BadRequest); | ||
ProducesProblem(StatusCodes.Status404NotFound); | ||
ProducesProblem(StatusCodes.Status412PreconditionFailed); | ||
Summary("Delete an existing order."); | ||
Description("Delete an existing order"); | ||
} | ||
|
||
public override async Task<IResult> HandleAsync(Request request) | ||
{ | ||
var command = MapToCommand(request); | ||
var result = await SendAsync(command).ConfigureAwait(false); | ||
var response = MapToResponse(result); | ||
return TypedResults.Ok(response); | ||
} | ||
var eTag = Context.Request.Headers.IfMatch; | ||
|
||
private static DeleteOrderCommand MapToCommand(Request request) | ||
{ | ||
return new DeleteOrderCommand(request.OrderId); | ||
var command = MapToCommand(request, eTag); | ||
await SendAsync(command).ConfigureAwait(false); | ||
return TypedResults.NoContent(); | ||
} | ||
|
||
private static Response MapToResponse(DeleteOrderResult result) | ||
private static DeleteOrderCommand MapToCommand(Request request, string? etag) | ||
{ | ||
return new Response(result.IsSuccess); | ||
return new DeleteOrderCommand(request.OrderId, etag); | ||
Check warning on line 31 in src/Services/Order.Command/Order.Command.API/Endpoints/DeleteOrder/Endpoint.cs GitHub Actions / build
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.