forked from sanchezvem/PyroFetes
17:17 09/10
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user