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