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