forked from sanchezvem/PyroFetes
34 lines
907 B
C#
34 lines
907 B
C#
using PyroFetes.DTO.Classification.Request;
|
|
using PyroFetes.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);
|
|
|
|
}
|
|
} |