Téléverser les fichiers vers "/"

This commit is contained in:
2025-10-08 15:01:07 +02:00
parent 373e9b91a5
commit 16c87e73dd
5 changed files with 181 additions and 0 deletions

34
CreateEffectEndpoint.cs Normal file
View File

@@ -0,0 +1,34 @@
using API.DTO.Effect.Request;
using API.DTO.Effect.Response;
using FastEndpoints;
namespace API.Endpoints.Effect;
public class CreateEffectEndpoint(AppDbContext appDbContext) : Endpoint<CreateEffectDto, GetEffectDto>
{
public override void Configure()
{
Post("/effect/create");
AllowAnonymous();
}
public override async Task HandleAsync(CreateEffectDto req, CancellationToken ct)
{
Models.Effect effect = new()
{
Label = req.Label,
};
appDbContext.Effects.Add(effect);
await appDbContext.SaveChangesAsync(ct);
Console.WriteLine("Effect added");
GetEffectDto responseDto = new()
{
Id = effect.Id,
Label = req.Label,
};
await Send.OkAsync(responseDto, ct);
}
}