17:17 09/10

This commit is contained in:
2025-10-09 17:17:42 +02:00
parent 1734ec0219
commit 91b4aca2fa
76 changed files with 815 additions and 388 deletions

View File

@@ -1,6 +1,5 @@
using PyroFetes.DTO.Effect.Response;
using API.DTO.Effect.Response;
using FastEndpoints;
using Microsoft.AspNetCore.Authentication;
using Microsoft.EntityFrameworkCore;
namespace PyroFetes.Endpoints.Effect;
@@ -10,23 +9,23 @@ public class GetEffectRequest
public int Id { get; set; }
}
public class GetEffectEndpoint(PyroFetesDbContext appDbContext) : Endpoint<GetEffectRequest, GetEffectDto>
public class GetEffectEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<GetEffectRequest, GetEffectDto>
{
public override void Configure()
{
Get("/api/effect/{@id}", x => new { x.Id });
Get("/effect/{@id}", x => new { x.Id });
AllowAnonymous();
}
public override async Task HandleAsync(GetEffectRequest req, CancellationToken ct)
{
Models.Effect? effect = await appDbContext
Models.Effect? effect = await pyrofetesdbcontext
.Effects
.SingleOrDefaultAsync(x => x.Id == req.Id, cancellationToken: ct);
if (effect == null)
{
Console.WriteLine($"Aucun effet avec l'ID {req.Id} trouvé.");
Console.WriteLine("Aucun effet avec l'ID {req.Id} trouvé.");
await Send.NotFoundAsync(ct);
return;
}