コード例 #1
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);

                //DTO the Body
                dto.Body = model.Body;
                //save
                db.SaveChanges();
            }
            //set tempdata message
            TempData["Success Message"] = "You Have Edit Sidebar !";

            //redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #2
0
        public ActionResult EditSidebar()
        {
            //Declare model
            SidebarVM model;

            using (TicketAppDB db = new TicketAppDB())
            {
                //Get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);

                //Init model
                model = new SidebarVM(dto);
            }


            //Return view with model
            return(View(model));
        }
コード例 #3
0
        public ActionResult EditSidebar()
        {
            //Declare Model
            SidebarVM model;

            using (Db db = new Db())
            {
                //Get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);
                //Init Model
                model = new SidebarVM(dto);
            }



            //Return View with Model
            return(View(model));
        }
コード例 #4
0
        // POST : Admin/Pages/EditSidebar
        public ActionResult EditSideBar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                // Get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);
                // DTO the body
                dto.Body = model.Body;
                // Save
                db.SaveChanges();
            }

            // Set template message
            TempData["SM"] = "You have editted the Sidebar";
            // Redirect

            return(RedirectToAction("EditSideBar"));
        }
コード例 #5
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                SidebarDTO dto = db.Sidebar.Find(1);


                dto.Body = model.Body;

                db.SaveChanges();
            }


            TempData["SM"] = "Вы отрадкатировалли баннер";


            return(RedirectToAction("EditSidebar"));
        }
コード例 #6
0
ファイル: PagesController.cs プロジェクト: bi11ys/asp1
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //get the dto
                SidebarDTO dto = db.Sidebar.Find(1);
                //dto the body
                dto.Body = model.Body;

                //save
                db.SaveChanges();
            }
            //set tempdata message
            TempData["SM"] = "You have edited the sidebar!";

            //redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #7
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));
            }
        }
        public ActionResult EditSidebar()
        {
            // declare model
            SidebarVM model;

            using (Db db = new Db())
            {
                //get dto
                SidebarDTO dto = db.Sidebar.Find(1);

                //init model
                model = new SidebarVM(dto);
            }


            //return view model
            return(View(model));
        }
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Получаем данные из DTO
                SidebarDTO dto = db.Sidebars.Find(1); //Говнокод!

                //Присваиваем данные в тело (в свойство Body)
                dto.Body = model.Body;

                //Сохраняем
                db.SaveChanges();
            }
            //Присваиваем сообщение в TempData
            TempData["SM"] = "You have edited the sidebar!";

            //Переадресовываем пользователя
            return(RedirectToAction("EditSidebar"));
        }
コード例 #10
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Получаем данные из DTO
                SidebarDTO dto = db.Sidebars.Find(1);

                //Присваиваем данные в тело (в свойство Body
                dto.Body = model.Body;

                //Сохранение
                db.SaveChanges();
            }
            //Сообщение об удачном редактировании
            TempData["SM"] = "Удачно отредактировано епта";

            //Переадресация полльзователя на даннную страницу
            return(RedirectToAction("EditSidebar"));
        }
コード例 #11
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Получаем данные из бд
                SidebarDTO dto = db.Sidebars.Find(1);

                //Присваимаем данные в body
                dto.Body = model.Body;

                //Сохраняем изменения
                db.SaveChanges();
            }
            //Присваиваем сообщение tempdata
            TempData["SM"] = "You have edited the sidebar";

            //Переадресация пользователя
            return(RedirectToAction("EditSidebar"));
        }
コード例 #12
0
        public ActionResult Editsidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                // Get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);

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

                // Save
                db.SaveChanges();
            }
            // Set TempData message
            TempData["SuccessMessage"] = "Your changes to the sidebar were saved successfully";

            // Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #13
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Get the dto
                SidebarDTO dto = db.Sidebar.Find(1);

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

                //save
                db.SaveChanges();
            }
            //set tempdata message
            TempData["SM"] = "Sidebar updated successfully";

            //Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #14
0
ファイル: PagesController.cs プロジェクト: Boonczek/ShopUZ
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Pobieramy Sidebar DTO
                SidebarDTO dto = db.Sidebar.Find(1);

                //Modyfikacja Sidebar
                dto.Body = model.Body;

                //Zapis w bazie danych
                db.SaveChanges();
            }

            //Ustawiwamy komunikat o modyfikacji Sidebar
            TempData["SM"] = "Zmodyfikowałeś Pasek Boczny";
            //Przekierowanie Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #15
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            if (ModelState.IsValid)
            {
                SidebarDTO dto = new SidebarDTO
                {
                    Id   = model.Id,
                    Body = model.Body
                };

                db.Entry(dto).State = EntityState.Modified;
                db.SaveChanges();

                TempData["SM"] = "You have edited the sidebar!";

                return(RedirectToAction("EditSidebar"));
            }
            return(View(model));
        }
コード例 #16
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //get data from DTO
                SidebarDTO dto = db.Sidebars.Find(1);//BadCode

                //assign data in body, property Body
                dto.Body = model.Body;

                //save
                db.SaveChanges();
            }

            //message about success TempData
            TempData["SM"] = "You have edited the sidebar";

            //redirect user
            return(RedirectToAction("EditSidebar"));
        }
コード例 #17
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (DB db = new DB())
            {
                SidebarDTO dto;
                dto = db.Sidebar.Find(1);

                if (dto == null)
                {
                    return(Content("404"));
                }

                dto.Body = model.Body;
                db.SaveChanges();
            }

            TempData["SM"] = "Success!";

            return(RedirectToAction("EditSidebar"));
        }
コード例 #18
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                // Get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);

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

                // Save
                db.SaveChanges();
            }

            // Set TempData message
            TempData["SM"] = "Bocna traka je izmenjena!!";

            // Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #19
0
ファイル: PagesController.cs プロジェクト: Aoll11/A
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Получить данные из DTO
                SidebarDTO dto = db.Sidebars.Find(1); //Временно

                //Присвоить данные в свойство Body
                dto.Body = model.Body;

                //Сохраняем
                db.SaveChanges();
            }
            //Присваиваем значение в TempData
            TempData["SM"] = "You have edited the sidebar!";

            //Переадресация пользователя

            return(RedirectToAction("EditSidebar")); //Переадресовываем на одноимённый GET метод!
        }
コード例 #20
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                // loading Sidebar DTO
                SidebarDTO dto = db.Sidebar.Find(1);

                // modification Sidebar
                dto.Body = model.Body;


                db.SaveChanges();
            }

            //message
            TempData["SM"] = "Sidebar has been modified";

            // Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #21
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Получить данные из бд(DTO)
                SidebarDTO dto = db.Sidebars.Find(1);                   //Говнакодинг!!!! Исправлю!

                //Присвоить данные в тело (в свойство Body)
                dto.Body = model.Body;

                //Сохранить изменения
                db.SaveChanges();
            }

            //Выводим сообщение с помощью TempData
            TempData["SM"] = "You have edited the sidebar!";

            //Переадресация пользователя
            return(RedirectToAction("EditSidebar"));
        }
コード例 #22
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                // pobieranie Sidebar DTO
                SidebarDTO dto = db.Sidebar.Find(1);

                // modyfikujemy Sidebar
                dto.Body = model.Body;

                // zapis na bazie
                db.SaveChanges();
            }

            // ustawienie komunikatu o modyfikacji Sidebar
            TempData["SM"] = "Zmodyfikowales Pasek Boczny";

            // Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #23
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                // get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);

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

                //save
                db.SaveChanges();
            }

            // Set TempData Message
            TempData["SM"] = "You have edited the sidebar.";

            //Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #24
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                // pobieramy Sidebar DTO
                SidebarDTO dto = db.Sidebar.Find(1);

                // modyfikacja Sidebar
                dto.Body = model.Body;

                // Zapis na bazie
                db.SaveChanges();
            }

            // Ustawiamy komunikat o modyfikacji Sidebar
            TempData["SM"] = "Zmodyfikowałeś pasek boczny";

            // Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #25
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Получить данные из бд
                SidebarDTO dto = db.Sidebars.Find(1); // Жесткое значение в коде не желательно добавлять, исправить.


                //Присвоить данные в тело (в свойство Body)
                dto.Body = model.Body;

                //Сохраняем
                db.SaveChanges();
            }
            //Присваиваем сообщение в TempData
            TempData["Successful message"] = "You have edited the sidebar!";

            //Переадресовываем пользователя
            return(RedirectToAction("EditSidebar"));
        }
コード例 #26
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (TicketAppDB db = new TicketAppDB())
            {
                //Get the DTO
                SidebarDTO dto = db.Sidebar.Find(1);

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

                //Save
                db.SaveChanges();
            }

            //Set TempData message
            TempData["SM"] = "You have edited the sidebar!";

            //Redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #27
0
        public ActionResult EditSidebar(SidebarVM model)
        {
            using (Db db = new Db())
            {
                //Получаем данные (DTO)
                SidebarDTO dto = db.Sidebars.Find(1); //Ещё говнокод, по той же причине

                //Присваиваем данные в тело
                dto.Body = model.Body;

                //Сохраняем
                db.SaveChanges();
            }

            //Присваиваем сообщение в TempData
            TempData["SM"] = "You have edited the sidebar!";

            //Переадресовываем
            return(RedirectToAction("EditSidebar"));
        }
コード例 #28
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"));
            }
        }
コード例 #29
0
ファイル: PagesController.cs プロジェクト: tutul2010/CmsApp
        public ActionResult EditSidebar(SidebarVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (var db = new Db())
            {
                //get data
                SidebarDTO dto = db.Sidebar.Find(1);

                //set dto
                dto.Body = model.Body;
                //update
                db.SaveChanges();
            }
            //set msg
            TempData["SM"] = "You have edited a  sidebar !";
            //redirect
            return(RedirectToAction("EditSidebar"));
        }
コード例 #30
0
        //Post : Admin/Pages/EditSidebar
        public ActionResult EditSidebar(SidebarVM model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (Db db = new Db())
            {
                //Get The DTO
                SidebarDTO oSidebarDTO = db.Sidebar.Find(1);

                //DTO the Body
                oSidebarDTO.Body = model.Body;

                //Save DTO
                db.SaveChanges();
            }
            //Set TempData message
            TempData["SM"] = "You have edited the sidebar";
            //Redirect
            return(RedirectToAction("EditSidebar"));
        }