-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderEndpoints.cs
More file actions
56 lines (48 loc) · 2.42 KB
/
OrderEndpoints.cs
File metadata and controls
56 lines (48 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using Microsoft.AspNetCore.Http.HttpResults;
using minimalAPIStructure.Endpoints.Orders.DeleteOrder;
using minimalAPIStructure.Endpoints.Orders.GetOrderById;
using minimalAPIStructure.Endpoints.Orders.GetOrders;
using minimalAPIStructure.Endpoints.Orders.CreateOrder;
using minimalAPIStructure.Endpoints.Orders.UpdateOrder;
namespace minimalAPIStructure.Endpoints.Orders
{
public static class OrderEndpoints
{
public static IEndpointRouteBuilder MapOrderEndpoints(this IEndpointRouteBuilder route)
{
var group = route.MapGroup("/orders")
.WithTags("Orders");
group.MapGet("", GetOrdersHandler.Handle)
.Produces<IEnumerable<GetOrdersResponse>>(StatusCodes.Status200OK)
.WithName(nameof(GetOrdersHandler))
.WithSummary("Get Orders")
.WithDescription("Get a list of all orders."); ;
group.MapGet("{id:int}", GetOrderByIdHandler.Handle)
.Produces<GetOrderByIdResponse>(StatusCodes.Status200OK)
.Produces(StatusCodes.Status404NotFound)
.WithName(nameof(GetOrderByIdHandler))
.WithSummary("Get Order by Id")
.WithDescription("Get detailed information about a specific order."); ;
group.MapPost("", CreateOrderHandler.Handle)
.Produces<CreateOrderResponse>(StatusCodes.Status201Created)
.Produces(StatusCodes.Status400BadRequest)
.WithName(nameof(CreateOrderHandler))
.WithSummary("Create Order")
.WithDescription("Create a new order");
group.MapPut("{id:int}", UpdateOrderHandler.Handle)
.Produces<UpdateOrderResponse>(StatusCodes.Status201Created)
.Produces(StatusCodes.Status400BadRequest)
.Produces(StatusCodes.Status404NotFound)
.WithName(nameof(UpdateOrderHandler))
.WithSummary("Update Order")
.WithDescription("Update an existing order");
group.MapDelete("{id:int}", DeleteOrderHandler.Handle)
.Produces(StatusCodes.Status204NoContent)
.Produces(StatusCodes.Status404NotFound)
.WithName(nameof(DeleteOrderHandler))
.WithSummary("Delete Order")
.WithDescription("Delete an existing order by Id.");
return group;
}
}
}