using API.DTO.Effect.Request; using API.DTO.Effect.Response; using FastEndpoints; namespace PyroFetes.Endpoints.Effect; public class CreateEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint { public override void Configure() { Post("Api/effects"); AllowAnonymous(); } public override async Task HandleAsync(CreateEffectDto req, CancellationToken ct) { Models.Effect effect = new() { Label = req.Label, }; pyrofetesdbcontext.Effects.Add(effect); await pyrofetesdbcontext.SaveChangesAsync(ct); Console.WriteLine("Effect added"); GetEffectDto responseDto = new() { Id = effect.Id, Label = req.Label, }; await Send.OkAsync(responseDto, ct); } }