public ActionResult Edit(tbl_SystemContent content) { if (ModelState.IsValid) { db.Entry(content).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(content); }
public ActionResult AddBanner(tbl_SystemContent content, HttpPostedFileBase file) { content.PropertyContent = file.FileName; if (ModelState.IsValid) { if (file != null) { char DirSeparator = System.IO.Path.DirectorySeparatorChar; string FilesPath = "~\\Images"; string full_path = Server.MapPath(FilesPath).Replace("SystemContent", "").Replace("AddBanner", ""); if (content.PropertyContent + "" != "") FileUpload.DeleteFile(content.PropertyContent, full_path); content.PropertyContent = FileUpload.UploadFile(file, full_path); } db.Entry(content).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(content); }