finalisation des endpoints
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using FastEndpoints;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PF3.DTO.SoundCategory.Request;
|
||||
using PyroFetes.DTO.SoundCategory.Request;
|
||||
|
||||
namespace PF3.Endpoints.SoundCategory;
|
||||
namespace PyroFetes.Endpoints.SoundCategory;
|
||||
|
||||
public class DeleteSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
|
||||
public class DeleteSoundCategoryEndpoint(PyroFetesDbContext pf3DbContext) : Endpoint<IdSoundCategoryDto>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -14,14 +14,14 @@ public class DeleteSoundCategoryEndpoint(PF3DbContext pf3DbContext) : Endpoint<I
|
||||
|
||||
public override async Task HandleAsync(IdSoundCategoryDto req, CancellationToken ct)
|
||||
{
|
||||
var soundCategory = await pf3DbContext.SoundsCategorys.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
||||
var soundCategory = await pf3DbContext.SoundCategories.FirstOrDefaultAsync(st => st.Id == req.Id, ct);
|
||||
if (soundCategory is null)
|
||||
{
|
||||
await Send.NotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
pf3DbContext.SoundsCategorys.Remove(soundCategory);
|
||||
pf3DbContext.SoundCategories.Remove(soundCategory);
|
||||
await pf3DbContext.SaveChangesAsync(ct);
|
||||
|
||||
await Send.OkAsync(ct);
|
||||
|
||||
Reference in New Issue
Block a user