21 lines
539 B
C#
21 lines
539 B
C#
using Knots.DTO.Key;
|
|
using FastEndpoints;
|
|
|
|
namespace Knots.Endpoints.Key;
|
|
|
|
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);
|
|
}
|
|
} |