Skip to content

Commit

Permalink
order command update order (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad088 authored Oct 16, 2024
1 parent 9214769 commit fd46315
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void MapEndpoint()
public override async Task<IResult> HandleAsync(Request request, ISender sender)
{
var command = request.Adapt<CreateOrderCommand>();
var result = await sender.Send(command).ConfigureAwait(false);
var result = await sender.Send(command, CancellationToken).ConfigureAwait(false);
var response = result.Adapt<Response>();
return Results.Created($"/order/{response.OrderId}", response);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
using Mapster;
using MediatR;
using Order.Command.Application.Orders.Commands.UpdateOrder;

namespace Order.Command.API.Endpoints.UpdateOrder;

public class Endpoint
public class Endpoint : EndpointBase<Request, Response>
{

public override void MapEndpoint()
{
Put("/order", HandleAsync);
Name("CreateOrder");
Produces(StatusCodes.Status201Created);
ProducesProblem(StatusCodes.Status400BadRequest);
ProducesProblem(StatusCodes.Status404NotFound);
Summary("Creates a new order");
Description("Creates a new order");
}

public override async Task<IResult> HandleAsync(Request request, ISender sender)
{
var command = request.Adapt<UpdateOrderCommand>();
var result = await sender.Send(command, CancellationToken).ConfigureAwait(false);
var response = result.Adapt<Response>();
return TypedResults.Ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Order.Command.Application.Dtos;

namespace Order.Command.API.Endpoints.UpdateOrder;

public record Request(OrderDto OrderDto);
public record Response(bool Success);

0 comments on commit fd46315

Please sign in to comment.