コード例 #1
0
        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);
        }
コード例 #2
0
 //insert
 public bool addPage(Navigation nav)
 {
     using (objContent)
     {
         objContent.Navigations.InsertOnSubmit(nav);
         //commit insert with db
         objContent.SubmitChanges();
         return true;
     }
 }
コード例 #3
0
 public ActionResult AddContentDelete(int id, Navigation nav)
 {
     //Selection will be deleted from the database
     try
     {
         objContent.deletePage(id);
         return RedirectToAction("AddContentIndex");
     }
     catch
     {
         return View();
     }
 }
コード例 #4
0
        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();
        }
コード例 #5
0
 partial void DeleteNavigation(Navigation instance);
コード例 #6
0
 partial void UpdateNavigation(Navigation instance);
コード例 #7
0
 partial void InsertNavigation(Navigation instance);