Exemple #1
0
        //GET: Admin/Pages/EditSidebar
        public ActionResult EditSidebar()
        {
            //declare model
            sidebarVM model;

            using (Db db = new Db())
            {
                //get the dto
                sidebarDTO dto = db.Sidebars.Find(1);
                // init model
                model = new sidebarVM(dto);
            }
            //return view with model
            return(View(model));
        }
Exemple #2
0
        //Post: Admin/Pages/EditSidebar
        public ActionResult EditSidebar(sidebarVM model)
        {
            using (Db db = new Db())
            {
                //get dto
                sidebarDTO dto = db.Sidebars.Find(1);
                //dto the body
                dto.Body = model.Body;
                //save
                db.SaveChanges();
                //temp message
                TempData["SM"] = "Side bas has been edited";
            }
            //redirect

            return(RedirectToAction("EditSidebar"));
        }