public JsonResult AjoutRessourceAction(int ressourceId, int tacheId, int q) { Ressource res = new Ressource(); TachRessource tachRs = new TachRessource(); tachRs.quantite = q; tachRs.RessourceId = ressourceId; tachRs.TacheId = tacheId; res = Rs.GetById(ressourceId); if (res.quantite >= q) { res.quantite = res.quantite - q; if (res.quantite == 0) { res.etat = (EtatRs)2; } var newQte = res.quantite; Rs.Update(res); Rs.Commit(); TR.Add(tachRs); TR.Commit(); return(Json(new { qte = newQte })); } // cs.AddResourceToTache(tache, ressource); return(Json(new { qte = res.quantite })); }