forked from sanchezvem/PyroFetes
commentaire endpoint
This commit is contained in:
@@ -8,27 +8,27 @@ public class UpdateClassificationEndpoint(PyroFetesDbContext pyrofetesdbcontext)
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/api/classifications");
|
||||
AllowAnonymous();
|
||||
Put("/api/classifications"); //Met à jour la classification en fonction de l'id
|
||||
AllowAnonymous(); //Autorise l'accès sans authentification
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateClassificationDto req, CancellationToken ct)
|
||||
{
|
||||
|
||||
Models.Classification classification = new()
|
||||
Models.Classification classification = new() //Met à jour la classification
|
||||
{
|
||||
Label = req.Label
|
||||
};
|
||||
pyrofetesdbcontext.Add(classification);
|
||||
await pyrofetesdbcontext.SaveChangesAsync(ct);
|
||||
pyrofetesdbcontext.Add(classification); //ajoute la classification dans la bdd
|
||||
await pyrofetesdbcontext.SaveChangesAsync(ct); //Sauvegarde les changements
|
||||
|
||||
GetClassificationDto response = new()
|
||||
GetClassificationDto response = new() //renvoie l'id et le nom
|
||||
{
|
||||
Id = req.Id,
|
||||
Label = req.Label
|
||||
};
|
||||
|
||||
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