From 94ea571a429c1bda4f3d038917b12d86a0840296 Mon Sep 17 00:00:00 2001 From: kieva Date: Wed, 8 Oct 2025 16:39:11 +0200 Subject: [PATCH] Ajouter PyroFetes/Endpoints/Effect/CreateEffectEndpoint --- .../Endpoints/Effect/CreateEffectEndpoint | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 PyroFetes/Endpoints/Effect/CreateEffectEndpoint diff --git a/PyroFetes/Endpoints/Effect/CreateEffectEndpoint b/PyroFetes/Endpoints/Effect/CreateEffectEndpoint new file mode 100644 index 0000000..a4eb0d7 --- /dev/null +++ b/PyroFetes/Endpoints/Effect/CreateEffectEndpoint @@ -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 +{ + 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); + } +} \ No newline at end of file