public async Task <ActionResult> FEdit([Bind(Include = "AchatID,FournisseurID,Price,Remise,Delais,State")] AchaFournisseur af, int nid, int fid) { if (ModelState.IsValid) { af.ID = fid; db.Entry(af).State = EntityState.Modified; await db.SaveChangesAsync(); } return(RedirectToAction("Detail", new { id = nid })); }
public async Task <ActionResult> FAdd([Bind(Include = "AchatID,FournisseurID,Price,Remise,Delais")] AchaFournisseur af, int achatid, int fournisseurid, int nid) { if (ModelState.IsValid && ApteAddFournisseur(achatid) && ExistFournisseur(achatid, fournisseurid)) { af.AchatID = achatid; af.FournisseurID = fournisseurid; db.AchaFournisseurs.Add(af); await db.SaveChangesAsync(); } return(RedirectToAction("Detail", new { id = nid })); }
public ActionResult Detail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AchaFournisseur n = db.AchaFournisseurs.Find(id); if (n == null) { return(HttpNotFound()); } return(View(n)); }
public async Task <ActionResult> Fournisseur(int?id, int?fid, string lbl) { AchaFournisseur af = await db.AchaFournisseurs.FindAsync(fid); Achat a = await db.Achats.FindAsync(id); ApplicationUser current = db.Users.Where(u => u.UserName == User.Identity.Name).First(); if (a == null || af == null) { return(HttpNotFound()); } af.State = StateFournisseur.Chose; a.State = StateDemande.DemandeConfirmerFournisseur; db.Entry(af).State = EntityState.Modified; db.Entry(a).State = EntityState.Modified; var A = new Models.Avis { AchatID = a.ID, Accept = true, Lbl = lbl, User = current, Code = AvisCode.demandeur }; Notification notif = new Notification { AchatID = af.AchatID, Role = SecurityRole.DAF, Lbl = "Demande choisir Fournisseur" }; db.Notifications.Add(notif); db.Avis.Add(A); await db.SaveChangesAsync(); return(RedirectToAction("Detail", new { id = a.ID })); }
public async Task <ActionResult> Fournisseur(int?id, int?fid, string lbl) { Notification notification = await db.Notifications.FindAsync(id); AchaFournisseur af = await db.AchaFournisseurs.FindAsync(fid); Achat a = await db.Achats.FindAsync(notification.AchatID); ApplicationUser current = db.Users.Where(u => u.UserName == User.Identity.Name).First(); if (notification == null || af == null) { return(HttpNotFound()); } notification.Etat = true; af.State = StateFournisseur.Chose; a.State = StateDemande.DemandeConfirmerFournisseur; db.Entry(notification).State = EntityState.Modified; db.Entry(af).State = EntityState.Modified; db.Entry(a).State = EntityState.Modified; var A = new Models.Avis { AchatID = notification.AchatID, Accept = true, Lbl = lbl, User = current, Code = AvisCode.demandeur }; db.Avis.Add(A); await db.SaveChangesAsync(); return(RedirectToAction("Fournisseur")); }