using FastEndpoints; using PyroFetes.DTO.SoundCategory.Request; using PyroFetes.DTO.SoundCategory.Response; namespace PyroFetes.Endpoints.SoundCategory; public class CreateSoundCategoryEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint { public override void Configure() { Post("/api/soundcategorys"); AllowAnonymous(); } public override async Task HandleAsync(CreateSoundCategoryDto req, CancellationToken ct) { var soundCategory = new PyroFetes.Models.SoundCategory { Name = req.Name, }; pyroFetesDbContext.SoundCategories.Add(soundCategory); await pyroFetesDbContext.SaveChangesAsync(ct); var result = new ReadSoundCategoryDto { Id = soundCategory.Id, Name = soundCategory.Name }; await Send.OkAsync(result, ct); } }