public ActionResult AddContentInsert(Navigation nav, HttpPostedFileBase file) { //Will check all the data regarding their validation , and if they were valid ,they are inserted into database and then redirecting to the index view . /*this is for image upload*/ if (ModelState.IsValid) { if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Content/images/addcontent/") + file.FileName); nav.content_image = file.FileName; } objContent.addPage(nav); return RedirectToAction("AddContentIndex"); } if (ModelState.IsValid) { try { objContent.addPage(nav); return RedirectToAction("AddContentIndex"); } catch { return View(nav); } } return View(nav); }
//insert public bool addPage(Navigation nav) { using (objContent) { objContent.Navigations.InsertOnSubmit(nav); //commit insert with db objContent.SubmitChanges(); return true; } }
public ActionResult AddContentDelete(int id, Navigation nav) { //Selection will be deleted from the database try { objContent.deletePage(id); return RedirectToAction("AddContentIndex"); } catch { return View(); } }
public ActionResult AddContentUpdate(int id, Navigation nav, HttpPostedFileBase file) { //Will check all the data regarding their validation , and if they were valid ,they are updated into database and then redirecting to the index view . /*this is for image upload*/ if (ModelState.IsValid) { if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Content/images/addcontent/") + file.FileName); nav.content_image = file.FileName; } objContent.updatePage(id, nav.title, nav.subtitle, nav.intro, nav.description, nav.content_text, nav.content_image); return RedirectToAction("AddContentIndex"); } return View(); }
partial void DeleteNavigation(Navigation instance);
partial void UpdateNavigation(Navigation instance);
partial void InsertNavigation(Navigation instance);