commentaire endpoint

This commit is contained in:
2025-11-05 22:38:55 +01:00
parent 4c0e7df9de
commit 3c32baac57
45 changed files with 475 additions and 479 deletions

View File

@@ -8,27 +8,27 @@ public class UpdateBrandEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
{
public override void Configure()
{
Put("/api/brands/{Id}");
AllowAnonymous();
Put("/api/brands/{Id}"); //Met à jour la marque en fonction de l'id
AllowAnonymous(); //Autorise l'accès sans authentification
}
public override async Task HandleAsync(UpdateBrandDto req, CancellationToken ct)
{
Models.Brand brand = new()
Models.Brand brand = new() //Met à jour la marque
{
Name = req.Name
};
pyrofetesdbcontext.Add(brand);
await pyrofetesdbcontext.SaveChangesAsync(ct);
pyrofetesdbcontext.Add(brand); //ajoute la marque dans la bdd
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements
GetBrandDto response = new()
GetBrandDto response = new() //renvoie l'id et le nom
{
Id = req.Id,
Name = req.Name
};
await Send.OkAsync(response, ct);
await Send.OkAsync(response, ct); //Envoie de la réponse réussite 200 au client
}
}