public ActionResult Edit(int id, Meuble m, HttpPostedFileBase file) { Meuble meuble = meubleService.GetById(m.IdMeuble); m.UserID = User.Identity.GetUserId <string>(); meuble.Titre = m.Titre; meuble.DatePublication = DateTime.Now; meuble.Image = file.FileName; meuble.PrixM = m.PrixM; meuble.Adresse = m.Adresse; meuble.Adresse = m.Adresse; var fileName = ""; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/"), fileName); file.SaveAs(path); } if (ModelState.IsValid) { meubleService.Update(meuble); meubleService.Commit(); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Create(MeubleVm meubleVM, HttpPostedFileBase file) { Meuble A = new Meuble(); A.Titre = meubleVM.Titre; A.DatePublication = DateTime.UtcNow; A.IdMeuble = meubleVM.IdMeuble; A.Description = meubleVM.Description; A.Image = file.FileName; A.PrixM = meubleVM.PrixM; A.Adresse = meubleVM.Adresse; var fileName = ""; if (file.ContentLength > 0) { var path = Path.Combine(Server.MapPath("~/Content/"), file.FileName); file.SaveAs(path); } // return RedirectToAction("CreateM"); //} //else A.UserID = User.Identity.GetUserId(); meubleService.Add(A); meubleService.Commit(); //var path = Path.Combine(Server.MapPath("~/Content/Upload/"), Image.FileName); //Image.SaveAs(path); return(RedirectToAction("AfficherMeuble")); }
public ActionResult DeleteConfirmed(int id) { Meuble meuble = db.Meubles.Find(id); db.Meubles.Remove(meuble); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id, FormCollection collection) { Meuble an = meubleService.GetById(id); meubleService.Delete(an); meubleService.Commit(); return(RedirectToAction("MesMeubles")); }
public ActionResult Edit([Bind(Include = "IdMeuble,Titre,Category,Image,Description,Prix,Livraison,Etat,Disponibilite,dateAnn,IdClient")] Meuble meuble) { if (ModelState.IsValid) { db.Entry(meuble).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdClient = new SelectList(db.Clients, "IdClient", "Nom", meuble.IdClient); return(View(meuble)); }
public ActionResult Create(Meuble meuble) { if (!ModelState.IsValid) { return(View(meuble)); } meubles.Add(meuble); return(RedirectToAction(nameof(Index))); }
// GET: Meubles/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Meuble meuble = db.Meubles.Find(id); if (meuble == null) { return(HttpNotFound()); } return(View(meuble)); }
public ActionResult Edit(int id, Meuble MVM) // FormCollection collection) { try { // TODO: Add update logic here Service.Update(MVM); Service.Commit(); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Meubles/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Meuble meuble = db.Meubles.Find(id); if (meuble == null) { return(HttpNotFound()); } ViewBag.IdClient = new SelectList(db.Clients, "IdClient", "Nom", meuble.IdClient); return(View(meuble)); }
// GET: Meuble/Delete/5 public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Meuble a = meubleService.GetById(id); if (a == null) { return(HttpNotFound()); } return(View(a)); }
public ActionResult Create(Meuble MVM, HttpPostedFileBase file) { try { MVM.Image = file.FileName; if (file.ContentLength > 0) { var path = Path.Combine(Server.MapPath("~/Content/"), file.FileName); file.SaveAs(path); } Service.Add(MVM); Service.Commit(); return(RedirectToAction("Index")); } catch (Exception e) { return(Json(e.Message)); } }
// GET: Meuble/Edit/5 public ActionResult Edit(int id) { //var userId = User.Identity.GetUserId(); //string UserName = US.GetById(userId).UserName; //string Phone = US.GetById(userId).Phone; //string mail = US.GetById(userId).Email; //string role = US.GetById(userId).Role; //ViewBag.Email = mail; //ViewBag.phone = Phone; //ViewBag.UserName = UserName; //ViewBag.Role = role; //ViewBag.authenticated = val1; Meuble p = meubleService.GetById(id); if (p == null) { return(HttpNotFound()); } return(View(p)); }