public ActionResult Create([Bind(Include = "id_demande,depart,arriver,date_depart,date_arriver,id_client")] Demande demande) { var olddemande = db.Demandes.Where(d => d.depart == demande.depart && d.arriver == demande.arriver && d.date_arriver == demande.date_arriver && d.date_depart == demande.date_depart).FirstOrDefault(); if (olddemande != null) { olddemande.number += 1; db.SaveChanges(); db.Entry(olddemande).State = EntityState.Modified; return(RedirectToAction("Index")); } else { if (ModelState.IsValid) { demande.number = 1; db.Demandes.Add(demande); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_client = new SelectList(db.Clients, "id_utilisateur", "id_utilisateur", demande.id_client); return(View(demande)); } }
public ActionResult Edit([Bind(Include = "id_utilisateur,nom_complet,mail,mdp,telephone,role")] Utilisateur utilisateur, string lieu, HttpPostedFileBase imagefile) { ViewBag.role = utilisateur.role; if (imagefile != null) { string namePic = Path.GetFileNameWithoutExtension(imagefile.FileName); string ext = Path.GetExtension(imagefile.FileName); namePic += System.DateTime.Now.ToString("yymmssfff") + ext; string path = Path.Combine(Server.MapPath("~/Content/UserPic/"), namePic); utilisateur.image = namePic; imagefile.SaveAs(path); } else { utilisateur.image = "default.jpg"; } if (ModelState.IsValid) { var societe = db.Societes.Find(utilisateur.id_utilisateur); db.Entry(utilisateur).State = EntityState.Modified; if (utilisateur.role == "societe") { societe.lieu = lieu; db.Entry(societe).State = EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("details", new { id = utilisateur.id_utilisateur })); } ViewBag.id_utilisateur = new SelectList(db.Admins, "id_utilisateur", "id_utilisateur", utilisateur.id_utilisateur); ViewBag.id_utilisateur = new SelectList(db.Clients, "id_utilisateur", "id_utilisateur", utilisateur.id_utilisateur); ViewBag.id_utilisateur = new SelectList(db.Societes, "id_utilisateur", "lieu", utilisateur.id_utilisateur); return(View()); }
public ActionResult Edit([Bind(Include = "id_bus,nom,nbr_place,climatiseur,tv,description,id_societe,id_navette,image")] Bus bus, HttpPostedFileBase imagefile) { if (Session["UserID"] != null) { int ids = int.Parse((Session["UserID"].ToString())); string namePic = Path.GetFileNameWithoutExtension(imagefile.FileName); string ext = Path.GetExtension(imagefile.FileName); namePic += System.DateTime.Now.ToString("yymmssfff") + ext; string path = Path.Combine(Server.MapPath("~/Content/"), namePic); bus.image = namePic; imagefile.SaveAs(path); if (ModelState.IsValid) { bus.nbr_place = (int)bus.nbr_place; db.Entry(bus).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = ids })); } ViewBag.id_navette = new SelectList(db.Navettes, "id_navette", "lieu_depart", bus.id_navette); ViewBag.id_societe = new SelectList(db.Societes, "id_utilisateur", "lieu", bus.id_societe); return(View(bus)); } else if (Session["UserID"] == null) { return(RedirectToAction("login", "Home")); } return(RedirectToAction("Index", "Home")); }
public ActionResult Edit([Bind(Include = "id_utilisateur")] Admin admin) { if (ModelState.IsValid) { db.Entry(admin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_utilisateur = new SelectList(db.Utilisateurs, "id_utilisateur", "nom_complet", admin.id_utilisateur); return(View(admin)); }
public ActionResult Edit([Bind(Include = "id_utilisateur,lieu")] Societe societe) { if (ModelState.IsValid) { db.Entry(societe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_utilisateur = new SelectList(db.Abonnements, "id_abonnement", "id_abonnement", societe.id_utilisateur); ViewBag.id_utilisateur = new SelectList(db.Utilisateurs, "id_utilisateur", "nom_complet", societe.id_utilisateur); return(View(societe)); }
public ActionResult Edit([Bind(Include = "id_navette,lieu_depart,lieu_arriver,date_depart,date_arriver")] Navette navette) { if (Session["UserID"] != null && Session["role"].ToString() == "admin") { if (ModelState.IsValid) { db.Entry(navette).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(navette)); } return(RedirectToAction("index", "home")); }
public ActionResult Edit([Bind(Include = "id_client,id_abonnement,duree")] Effectuer effectuer) { if (Session["UserID"] != null && Session["role"].ToString() == "client") { if (ModelState.IsValid) { db.Entry(effectuer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_abonnement = new SelectList(db.Abonnements, "id_abonnement", "id_abonnement", effectuer.id_abonnement); ViewBag.id_client = new SelectList(db.Clients, "id_utilisateur", "id_utilisateur", effectuer.id_client); return(View(effectuer)); } return(RedirectToAction("login", "home")); }
public ActionResult Edit([Bind(Include = "id_abonnement,date_debut,date_fin,id_navette,id_societe,prix")] Abonnement abonnement) { if (Session["UserID"] != null) { int id = int.Parse((Session["UserID"].ToString())); if (ModelState.IsValid) { db.Entry(abonnement).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { ids = id })); } ViewBag.id_navette = new SelectList(db.Navettes, "id_navette", "lieu_depart", abonnement.id_navette); ViewBag.id_societe = new SelectList(db.Societes, "id_utilisateur", "lieu", abonnement.id_societe); return(View(abonnement)); } else if (Session["UserID"] == null) { return(RedirectToAction("login", "Home")); } return(RedirectToAction("index", "Home")); }