-
-
Notifications
You must be signed in to change notification settings - Fork 96
/
Endpoint.cs
29 lines (27 loc) · 899 Bytes
/
Endpoint.cs
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
using HappyCode.NetCoreBoilerplate.BooksModule.Dtos;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using System.Data;
namespace HappyCode.NetCoreBoilerplate.BooksModule.Features.UpsertBook;
internal static class Endpoint
{
public static IEndpointRouteBuilder MapUpsertBookEndpoint(this IEndpointRouteBuilder endpoints)
{
endpoints
.MapPost(
"/",
async (
BookDto book,
IDbConnection db,
CancellationToken ct
) =>
{
await db.UpsertBookAsync(book, ct);
return Results.NoContent();
})
.Produces(StatusCodes.Status204NoContent)
.WithTags("Books");
return endpoints;
}
}