Files
PyroFetes-Sujet1/PyroFetes/Endpoints/Classification/UpdateClassificationEndpoint.cs
2025-10-16 17:03:51 +02:00

34 lines
894 B
C#

using API.DTO.Classification.Request;
using API.DTO.Classification.Response;
using FastEndpoints;
namespace PyroFetes.Endpoints.Classification;
public class UpdateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<UpdateClassificationDto, GetClassificationDto>
{
public override void Configure()
{
Put("/api/classifications");
AllowAnonymous();
}
public override async Task HandleAsync(UpdateClassificationDto req, CancellationToken ct)
{
Models.Classification classification = new()
{
Label = req.Label
};
pyrofetesdbcontext.Add(classification);
await pyrofetesdbcontext.SaveChangesAsync(ct);
GetClassificationDto response = new()
{
Id = req.Id,
Label = req.Label
};
await Send.OkAsync(response, ct);
}
}