public ActionResult Edit([Bind(Include = "Id,name,num_of_producta")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "Id,name,price,image,descroption,category_id")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.category_id = new SelectList(db.Categories, "Id", "name", product.category_id); return(View(product)); }
public ActionResult Edit([Bind(Include = "Id,name,price,description,category_id")] Product product, HttpPostedFileBase imgFile) { string path = ""; if (imgFile.FileName.Length > 0) { path = "~/images/" + Path.GetFileName(imgFile.FileName); imgFile.SaveAs(Server.MapPath(path)); } product.image = path; if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.category_id = new SelectList(db.Categories, "Id", "name", product.category_id); return(View(product)); }
public ActionResult Edit([Bind(Include = "Id,Name,Price,Image,Description,CID")] product product, HttpPostedFileBase imgFile) { if (ModelState.IsValid) { string path = ""; product p = new product(); product product1 = db.products.Find(p.Image); if (imgFile.FileName.Length > 0) { path = "~/Images/" + Path.GetFileName(imgFile.FileName); imgFile.SaveAs(Server.MapPath(path)); } product.Image = path; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Carts, "product_id", "product_id", product.Id); ViewBag.CID = new SelectList(db.categories, "CID", "CName", product.CID); return(View(product)); }