forked from sanchezvem/PyroFetes
commentaire endpoint
This commit is contained in:
@@ -6,23 +6,23 @@ namespace PyroFetes.Endpoints.Material;
|
||||
|
||||
public class GetAllMaterialsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : EndpointWithoutRequest<List<GetMaterialDto>>
|
||||
{
|
||||
public override void Configure()
|
||||
public override void Configure() //Configuration de l'endpoint
|
||||
{
|
||||
Get("Api/materials");
|
||||
AllowAnonymous();
|
||||
Get("Api/materials"); //Création d'un endpoint pour récupérer tous les matériaux grâce à la liste
|
||||
AllowAnonymous(); //Ignorer les requêtes non authentifiées
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials
|
||||
.Select(a => new GetMaterialDto
|
||||
List<GetMaterialDto> responseDto = await pyrofetesdbcontext.Materials //Création d'une liste qui récupère tous les matériaux de la bdd
|
||||
.Select(a => new GetMaterialDto //Sélectionne dans la liste chaque matériel
|
||||
{
|
||||
Id = a.Id,
|
||||
Label = a.Name,
|
||||
Quantity = a.Quantity,
|
||||
WarehouseId = a.WarehouseId,
|
||||
Id = a.Id, //Récupère l'id
|
||||
Label = a.Name, //Récupère le label
|
||||
Quantity = a.Quantity, //Récupère la quantité
|
||||
WarehouseId = a.WarehouseId, //Récupère l'id de l'entrepot
|
||||
}
|
||||
).ToListAsync(ct);
|
||||
await Send.OkAsync(responseDto, ct);
|
||||
).ToListAsync(ct); //Retourne la liste du matériel
|
||||
await Send.OkAsync(responseDto, ct); //Envoie de la réponse réussite 200 au client
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user