public ActionResult ImageEdit(int id, sliderimage image, HttpPostedFileBase ImagePath) { if (ImagePath != null && ImagePath.ContentLength > 0) { var fileName = Path.GetFileName(ImagePath.FileName); var path = Path.Combine(Server.MapPath("~/Content/Images"), fileName); ImagePath.SaveAs(path); image.ImagePath = fileName; } else { image.ImagePath = "test.jpg"; } if (ModelState.IsValid) { try { dbproduct.commitUpdate(id, image.ImagePath); return(RedirectToAction("Index")); } catch { return(View()); } } return(View()); }
public ActionResult DeleteImage(int Id, sliderimage img) { try { dbproduct.commitDelete(Id); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Index(HttpPostedFileBase ImagePath) { if (ImagePath != null && ImagePath.ContentLength > 0) { var fileName = Path.GetFileName(ImagePath.FileName); var path = Path.Combine(Server.MapPath("~/Content/Images"), fileName); ImagePath.SaveAs(path); var NewProduct = new sliderimage(); //NewProduct.ImagePath = path; NewProduct.ImagePath = fileName; dbproduct.commitInsert(NewProduct); } //return RedirectToAction("sliderAdmin", "SliderAdmin"); var img = dbproduct.getImages(); return(View(img)); }