Пример #1
0
        public ActionResult EditSidebar()
        {
            //Declare Model
            SidebarVM model;

            using (DataContext db = new DataContext())
            {
                //Need to get DTO
                SidebarDTOes dto = db.Sidebar.Find(1); //always going to be one that's why it's hard-coded

                //Initialize model
                model = new SidebarVM(dto);


                //return view with model
                return(View(model));
            }
        }
Пример #2
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (DataContext db = new DataContext())
            {
                //Get the DTO
                SidebarDTOes dto = db.Sidebar.Find(1);

                //DTO the body
                dto.Body = model.Body;

                //Save
                db.SaveChanges();

                //Set tempData
                TempData["SM"] = "You have successfully edited the Sidebar!";

                //Redirect
                return(RedirectToAction("EditSidebar"));
            }
        }
Пример #3
0
 public SidebarVM(SidebarDTOes row)
 {
     Id   = row.Id;
     Body = row.Body;
 }