public ActionResult EditOptions(int id) { ViewBag.cname = db.CustomizeSettings.FirstOrDefault(x => x.code == "cname"); CustomizeSetting selected = db.CustomizeSettings.Find(id); ViewBag.custom = selected.code; ViewData["code"] = selected.code; return(View()); }
public ActionResult EditOptions(FormCollection form, HttpPostedFileBase file) { ViewBag.cname = db.CustomizeSettings.FirstOrDefault(x => x.code == "cname"); string str = (Request.Form["code"]); CustomizeSetting custom = new CustomizeSetting(); custom = db.CustomizeSettings.FirstOrDefault(x => x.code == str); if ((Request.Form["name"] != null && Request.Form["code"] != "" && Request.Form["Description"] != "" && Request.Form["FullDescription"] != "" && file != null)) { string path = Path.Combine(Server.MapPath("~/Content/images/"), Path.GetFileName(file.FileName)); file.SaveAs(path); path = Path.Combine(Server.MapPath("~/Content/images/"), Path.GetFileName(file.FileName)); file.SaveAs(path); custom.path = "/Content/images/" + file.FileName; custom.name = Request.Form["name"]; custom.newprice = Request.Form["newprice"]; custom.fulldescription = Request.Form["FullDescription"]; custom.description = Request.Form["Description"]; db.Entry(custom); db.SaveChanges(); return(RedirectToAction("options", "admin")); } else { ViewBag.mess = "Fill the Form...."; return(View()); } }