forked from sanchezvem/PyroFetes
commentaire endpoint
This commit is contained in:
@@ -8,21 +8,21 @@ public class GetAllBrandsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/brands");
|
||||
AllowAnonymous();
|
||||
Get("/api/brands"); //Endpoint qui affiche toutes les marques
|
||||
AllowAnonymous(); //Autorise l'accès sans authentification
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
|
||||
List<GetBrandDto> responseDto = await pyrofetesdbcontext.Brands
|
||||
.Select(a => new GetBrandDto
|
||||
List<GetBrandDto> responseDto = await pyrofetesdbcontext.Brands //Création d'une liste qui récupère toutes les marques dans la bdd
|
||||
.Select(a => new GetBrandDto //Sélectionne dans la liste chaque marque
|
||||
{
|
||||
Id = a.Id,
|
||||
Name = a.Name,
|
||||
Id = a.Id, //Affiche l'id
|
||||
Name = a.Name, //Affiche le nom
|
||||
}
|
||||
).ToListAsync(ct);
|
||||
).ToListAsync(ct); //Retourne la liste de marque
|
||||
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user