Début endpoints

This commit is contained in:
2026-03-26 15:34:49 +01:00
parent df6e559f00
commit 579f50a2de
15 changed files with 182 additions and 158 deletions

View File

@@ -1,6 +1,21 @@
using Knots.DTO.Key;
using FastEndpoints;
namespace Knots.Endpoints.Key;
public class CreateKeyEndpoint
public class CreateKeyEndpoint(KnotsDbContext db, AutoMapper.IMapper mapper) : Endpoint<CreateKeyDto>
{
public override void Configure()
{
Post("/groups");
AllowAnonymous();
}
public override async Task HandleAsync(CreateKeyDto req, CancellationToken ct)
{
Models.Key? key = mapper.Map<Models.Key>(req);
db.Keys.Add(key);
await db.SaveChangesAsync(ct);
await Send.NoContentAsync(ct);
}
}