// GET: Tache public ActionResult AfficherTacheRessource(int id) { List <RessourceQuantiteModel> lc = new List <RessourceQuantiteModel>(); foreach (var cm in TR.GetAll()) { TachRessource c = new TachRessource(); if (cm.TacheId == id) { ViewBag.id = cm.TacheId; int R1; R1 = cm.RessourceId; foreach (var cm1 in Rs.GetAll()) { if (cm.RessourceId == cm1.id) { RessourceQuantiteModel c2 = new RessourceQuantiteModel(); c2.id = cm1.id; c2.nom = cm1.nom; c2.type = cm1.type; c2.quantite = cm1.quantite; c2.quantiteTache = cm.quantite; lc.Add(c2); } } } } return(View(lc)); }
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 })); }