public IActionResult Put(Guid id, [FromBody] FicheRetour ficheRetour) { var result = _Db.FichesRetours.Where(f => f.Id == id).FirstOrDefault(); if (result == null || ficheRetour.Id != id) { return(NotFound(string.Format("Fiche avec l'identifiant {0} est non trouvée", id))); } else { try { _Db.Update(ficheRetour); if (_Db.SaveChanges() != 0) { return(Ok(ficheRetour)); } else { return(Ok(string.Format("Aucune opération n'est effectuée!"))); } } catch (Exception ex) { return(BadRequest(string.Format("Echec de la modification de la fiche! : {0}", ex.ToString()))); } } }
public void AddFicheRetour(FicheRetour newFicheRetour) { // Convert new products to lookup of product foreach (var item in newFicheRetour.LignesProduits) { item.Produit = _ctx.Produits.Find(item.Produit.Id); } AddEntity(newFicheRetour); }