forked from sanchezvem/PyroFetes
AJout des DTO et endpoint sur le nouveau git
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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()
|
||||
{
|
||||
Post("/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);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user