public ActionResult EditPage(int id) { //Declare PageVM PageVM model; using (Db db = new Db()) { //GEt the page PageDTO dto = db.Pages.Find(id); //Confirm if page exists if (dto == null) { return(Content("This page does not exist")); } //initialize pageVM model = new PageVM(dto); } return(View(model)); }
//GET: Admin/Pages/PageDetails/id public ActionResult PageDetails(int id) { //Declare PageVM PageVM model; using (Db db = new Db()) { //GET the page PageDTO dto = db.Pages.Find(id); //confirm page exists if (dto == null) { return(Content("This page does not exist")); } //init pageVM model = new PageVM(dto); } //return page with view return(View(model)); }
public ActionResult Editpage(int id) { //declare pageVM PageVM model; using (Db db = new Db()) { //get the page PageDTO dto = db.Pages.Find(id); //confirm page exists if (dto == null) { return(Content("this page does not exists")); } //InIt PageVM model = new PageVM(dto); } //Return View with Model return(View()); }
public ActionResult EditPage(int id) { PageVM model; using (Db db = new Db()) { //pobieram strone z bazy o przekazanym id PageDTO dto = db.Pages.Find(id); //sprawdzam czy taka strona istnieje if (dto == null) { Content("Strona nieistnieje."); } model = new PageVM(dto); } return(View(model)); }
public ActionResult EditPage(int id) { PageVM pageVM = new PageVM(); using (BankDB bankDB = new BankDB()) { PagesDTO pagesDTO = bankDB.Pages.Find(id); if (pagesDTO == null) { return(Content("Страница не доступна")); } pageVM = new PageVM(pagesDTO); pageVM.categoryList = new SelectList(bankDB.Categories.ToList(), "Id", "Name"); } return(View(pageVM)); }
// GET: Admin/Pages/EditPage/id public ActionResult EditPage(int?id) { //Declare Page PageVM model; using (Db db = new Db()) { //Get the page PageDTO dto = db.Pages.Find(id); //Confirm page exists if (dto == null) { return(Content("The page does not exists")); } //int pageVM model = new PageVM(dto); } //Return view with model return(View(model)); }
// GET: Admin/Pages/PageDetails/1 public ActionResult PageDetails(int id) { //Declare PageVM PageVM model; using (Db db = new Db()) { //Get the Page PageDTO dto = db.Pages.Find(id); //Confirm the Page exists if (dto == null) { return(Content("The Page does not exist")); } //Init PageVM model = new PageVM(dto); } return(View(model)); }
// GET: Admin/Pages/PageDetails/id public ActionResult PageDetails(int id) { PageVM model; using (Db db = new Db()) { PagesDTO dto = db.Pages.Find(id); if (dto == null) { return(Content("The page doesn't exist.")); } model = new PageVM(dto); } return(View(model)); }
//Get : Admin/Pages/PageDetails/id public ActionResult PageDetails(int id) { //Deklarisanje PageVM PageVM page; using (ShoppingCartDB db = new ShoppingCartDB()) { //pronaci(get) stranicu PageDTO dto = db.Pages.Find(id); //potvrditi da postoji takva stranica if (dto == null) { return(Content("That page doesn't exist!!!")); } //Inicijalizacija PageVM page = new PageVM(dto); } return(View(page)); }
public ActionResult EditPage(int id) { //Deklarisanje PageVM-a PageVM page; using (ShoppingCartDB db = new ShoppingCartDB()) { //GET(Uzmi) Stranicu PageDTO dto = db.Pages.Find(id); //Potvrditi da postoji takva stranica if (dto == null) { return(Content("The Page doesn't exist!!!")); } //Inicijalizzacija PageVm-a page = new PageVM(dto); } //Vratit View sa modelom return(View(page)); }
public ActionResult EditPage(int?id) { if (id == null) { return(RedirectToAction("Index")); } PageVM model; using (Db db = new Db()) { PagesDTO dto = db.Pages.Find(id); if (dto == null) { TempData["EM"] = "This page dose not exist!"; return(RedirectToAction("Index")); } model = new PageVM(dto); } return(View(model)); }
public ActionResult EditPage(int id) { //объявим модель pagevm PageVM model; using (Db db = new Db()) { //получаем страницу PagesDTO dto = db.Pages.Find(id); //проверяем, доступна ли страница if (dto == null) { return(Content("The page does not exist")); } //инициализируем модель данных model = new PageVM(dto); } //возвращаем представление return(View(model)); }
//Get : Admin/Pages/PageDetails/id public ActionResult PageDetails(int id) { //Declate PageMV PageVM model; using (Db db = new Db()) { //Get Page PageDTO oPageDTO = db.Pages.Find(id); //Confirm Page exists if (oPageDTO == null) { return(Content("The Page Dos not exists")); } //Init PageVM model = new PageVM(oPageDTO); } //Return View With Model return(View(model)); }
public ActionResult EditPage(int id) { //Declare PageVM PageVM model; using (Db db = new Db()) { //Get The Page pageDTO dto = db.Pages.Find(id); //confirm page exist if (dto == null) { return(Content("The Page Doesn't Exist.")); } //initialize pageVM model = new PageVM(dto); } //return view with model return(View(model)); }
//GET:Admin/Pages/PageDetails/id public ActionResult PageDetails(int id) { //объявляем модель PageVM PageVM model; using (Db db = new Db()) { //получаем страницу PagesDTO dto = db.Pages.Find(id); //Подтверждаем что страница доступна if (dto == null) { return(Content("The page doesn't exist.")); } // ПРисваиваем модели информацию из базы model = new PageVM(dto); } //Возвращаем модель в представление return(View()); }
public ActionResult EditPage(PageVM model) { if (!ModelState.IsValid) { return(View(model)); } using (Db db = new Db()) { int id = model.Id; string slug = "home"; PageDTO dto = db.Pages.Find(id); dto.Title = model.Title; if (model.Slug != "home") { if (string.IsNullOrWhiteSpace(model.Slug)) { slug = model.Title.Replace(" ", "-").ToLower(); } else { slug = model.Slug.Replace(" ", "-").ToLower(); } } if (db.Pages.Where(x => x.Id != id).Any(x => x.Title == model.Title) || db.Pages.Where(x => x.Id != id).Any(x => x.Slug == slug)) { ModelState.AddModelError(" ", "Dati naslov vec postoji"); return(View(model)); } dto.Slug = slug; dto.Body = model.Body; dto.HasSidebar = model.HasSidebar; db.SaveChanges(); } TempData["SM"] = "Data stranica je izmenjena"; return(RedirectToAction("EditPage")); }
protected void Page_Load(object sender, EventArgs e) { SearchPower = base.AddPower(SearchPower); UserVM user = AuthServer.GetLoginUser(); int pgNow; int pgSize; int.TryParse(Request.Form["pgNow"], out pgNow); int.TryParse(Request.Form["pgSize"], out pgSize); DataSet ds = new DataSet(); using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString())) { using (SqlCommand cmd = new SqlCommand("usp_VaccineIn_xSearchLogin", sc)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@pgNow", pgNow); cmd.Parameters.AddWithValue("@pgSize", pgSize); cmd.Parameters.AddWithValue("@InOrgID", user.OrgID); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { sc.Open(); da.Fill(ds); } } } List <VaccineInPendingVM> list = new List <VaccineInPendingVM>(); PageVM rtn = new PageVM(); EntityS.FillModel(list, ds.Tables[0]); EntityS.FillModel(rtn, ds.Tables[1]); rtn.message = list; Response.ContentType = "application/json; charset=utf-8"; Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rtn)); Response.End(); }
public void Index_Post_Should_Redirect(string controllerName) { const string id = "123"; //arrange var returnPage = new PageVM { PageId = id, NextPageId = controllerName, PreviousPages = new List <PreviousPageVM>() }; var mockValidation = new Mock <IGdsValidation>(); var mockSession = new Mock <ISessionService>(); var mockLogger = new Mock <ILogger <FormController> >(); mockSession.Setup(x => x.GetPageById(id, false)).Returns(returnPage).Verifiable(); mockSession.Setup(x => x.GetUserSession()).Returns(new UserSessionVM { LocationName = "the service" }).Verifiable(); ApplicationSettings appSettings = new ApplicationSettings() { FormStartPage = id, ServiceNotFoundPage = "test1", DefaultBackLink = "test2" }; IOptions <ApplicationSettings> options = Options.Create(appSettings); var mockUrlHelper = new Mock <IUrlHelper>(); var sut = new FormController(mockValidation.Object, mockSession.Object, options, mockLogger.Object); sut.Url = mockUrlHelper.Object; //act var result = sut.Index(new CurrentPageVM { PageId = id }); //assert var redirectesult = result as RedirectToActionResult; redirectesult.ControllerName.Should().Be(controllerName); redirectesult.ActionName.Should().Be("Index"); mockSession.Verify(); }
public ActionResult AddPage(PageVM model) { if (!ModelState.IsValid) { return(View(model)); } using (Db db = new Db()) { string slug; PageDTO dto = new PageDTO(); dto.Title = model.Title; if (string.IsNullOrWhiteSpace(model.Slug)) { slug = model.Title.Replace(" ", " -").ToLower(); } else { slug = model.Slug.Replace(" ", " -").ToLower(); } if (db.Pages.Any(x => x.Title == model.Title) || db.Pages.Any(x => x.Slug == slug)) { ModelState.AddModelError("", "Naslov vec postoji!"); } dto.Slug = slug; dto.Body = model.Body; dto.HasSidebar = model.HasSidebar; dto.Sorting = 100; //Cuvanje DTO db.Pages.Add(dto); db.SaveChanges(); } TempData["SM"] = "Dodali ste novu stranicu"; return(RedirectToAction("AddPage")); }
public ActionResult EditPage(PageVM model) { if (!ModelState.IsValid) { return(View(model)); } using (DB db = new DB()) { int id = model.Id; string slug = "home"; PageDTO dto = db.Pages.Find(id); dto.Title = model.Title; if (model.Slug != "home") { if (string.IsNullOrWhiteSpace(model.Slug)) { slug = model.Title.Replace(" ", "-").ToLower(); } else { slug = model.Slug.Replace(" ", "-").ToLower(); } } if (db.Pages.Where(x => x.Id != id).Any(x => x.Title == model.Title) || db.Pages.Where(x => x.Id != id).Any(x => x.Slug == slug)) { ModelState.AddModelError("", "The Title or Slug Already Exists"); return(View(model)); } dto.Slug = slug; dto.Body = model.Body; dto.HasSidebar = model.HasSidebar; db.SaveChanges(); } TempData["SM"] = "Success!"; return(RedirectToAction("Index")); }
public IActionResult List(int page = 1) { if (int.TryParse(RouteData.Values["Id"]?.ToString(), out int wid)) { var uwo = Application.CommonService.UserWritingOneQuery(wid); if (uwo == null) { return(Redirect("/")); } var pag = new PaginationVM { PageNumber = Math.Max(page, 1), PageSize = 10 }; var vm = new PageVM() { Rows = Application.CommonService.ReplyOneQuery(Application.EnumService.ReplyType.UserWriting, wid.ToString(), pag), Pag = pag, Temp = uwo, Route = "/home/list/" + wid.ToString() }; if (User.Identity.IsAuthenticated) { var uinfo = new Application.UserAuthService(HttpContext).Get(); var listuc = db.UserConnection.Where(x => x.Uid == uinfo.UserId && x.UconnTargetType == Application.EnumService.ConnectionType.UserWriting.ToString() && x.UconnTargetId == wid.ToString()).ToList(); ViewData["uca1"] = listuc.Any(x => x.UconnAction == 1) ? "yes" : ""; ViewData["uca2"] = listuc.Any(x => x.UconnAction == 2) ? "yes" : ""; } return(View(vm)); } else { return(Redirect("/")); } }
// GET: Pages public ActionResult Index(string page = "") { if (page == "") { page = "home"; } // Deklaracija modela i dto PageVM model; PageDTO dto; // Provera da li stranica postoji using (Db db = new Db()) { if (!db.Pages.Any(x => x.Slug.Equals(page))) { return(RedirectToAction("Index", new { page = "" })); } } using (Db db = new Db()) { dto = db.Pages.Where(x => x.Slug == page).FirstOrDefault(); } // Postavljanje naslova na stranici ViewBag.PageTitle = dto.Title; if (dto.HasSidebar == true) { ViewBag.Sidebar = "Yes"; } else { ViewBag.Sidebar = "No"; } model = new PageVM(dto); return(View(model)); }
public ActionResultVM ReplyList(string id, int page = 1) { var vm = new ActionResultVM(); try { var uinfo = new UserAuthAid(HttpContext).Get(); var pag = new PaginationVM { PageNumber = Math.Max(page, 1), PageSize = 10 }; var list = Func.Common.ReplyOneQuery(EnumAid.ReplyType.GuffRecord, id, pag); //匿名用户,生成邮箱MD5加密用于请求头像 foreach (var item in list) { if (item.Uid == 0 && !string.IsNullOrWhiteSpace(item.UrAnonymousMail)) { item.Spare3 = CalcTo.MD5(item.UrAnonymousMail); } } var pvm = new PageVM() { Rows = list, Pag = pag }; vm.data = pvm; vm.Set(ARTag.success); } catch (Exception ex) { vm.Set(ex); ConsoleTo.Log(ex); } return(vm); }
// GET: Pages public ActionResult Index(string Page = "") { //Get/Set Page Slug if (Page == "") { Page = "home"; } //Declare model and DTO PageVM model; PageDTO oDto; //Check if page exsist using (Db db = new Db()) { if (!db.Pages.Any(x => x.Slug.Equals(Page))) { return(RedirectToAction("Index", new { Page = "" })); } } //Get Page DTO using (Db db = new Db()) { oDto = db.Pages.Where(x => x.Slug.Equals(Page)).SingleOrDefault(); } //Set Page Title ViewBag.PageTitle = oDto.Title; //Check for Sidebar if (oDto.HasSideBar == true) { ViewBag.Sidebar = "Yes"; } else { ViewBag.Sidebar = "No"; } //init model model = new PageVM(oDto); //return view with model return(View(model)); }
// GET: Index/{page} public ActionResult Index(string page = "") { if (page == "") { page = "home"; } PageVM model; PageDTO dto; using (Db db = new Db()) { if (!db.Pages.Any(x => x.Slug.Equals(page))) { return(RedirectToAction("Index", new { page = "" })); } } using (Db db = new Db()) { dto = db.Pages.Where(x => x.Slug == page).FirstOrDefault(); } ViewBag.PageTitle = dto.Title; if (dto.HasSidebar == true) { ViewBag.Sidebar = "Yes"; } else { ViewBag.Sidebar = "No"; } model = new PageVM(dto); return(View(model)); }
public ActionResultVM ReplyList(string id, int page = 1) { var vm = new ActionResultVM(); try { var uinfo = new Application.UserAuthService(HttpContext).Get(); var pag = new PaginationVM { PageNumber = Math.Max(page, 1), PageSize = 10 }; var list = Application.CommonService.ReplyOneQuery(Application.EnumService.ReplyType.GuffRecord, id, pag); //匿名用户,生成邮箱MD5加密用于请求头像 foreach (var item in list) { if (item.Uid == 0 && !string.IsNullOrWhiteSpace(item.UrAnonymousMail)) { item.Spare3 = Core.CalcTo.MD5(item.UrAnonymousMail); } } var pvm = new PageVM() { Rows = list, Pag = pag }; vm.Data = pvm; vm.Set(ARTag.success); } catch (Exception ex) { vm.Set(ex); Filters.FilterConfigs.WriteLog(HttpContext, ex); } return(vm); }
// GET: Index/{page} public ActionResult Index(string page = "") { //Get/set page slug if (page == "") { page = "home"; } //Declare model and DTO PageVM model; PageDTO dto; //Check if page exists using (Db db = new Db()) { if (!db.Pages.Any(x => x.Slug.Equals(page))) { return(RedirectToAction("Index", new { page = "" })); } } //Get page DTO using (Db db = new Db()) { dto = db.Pages.Where(x => x.Slug == page).FirstOrDefault(); } //Set page title ViewBag.PageTitle = dto.Title; //Check for sidebar if (dto.HasSideBar == true) { ViewBag.Sidebar = "Yes"; } else { ViewBag.SideBar = "No"; } //Init model model = new PageVM(dto); //Return view with model return(View(model)); }
public ActionResult EditPage(PageVM model) { if (!ModelState.IsValid) { return(View(model)); } using (Db db = new Db()) { int id = model.Id; string slug = "home"; PagesDTO dTO = db.pages.Find(id); dTO.Title = model.Title; if (model.Slug != "home") { if (string.IsNullOrWhiteSpace(model.Slug)) { slug = model.Title.Replace(" ", "-").ToLower(); } else { slug = model.Slug.Replace(" ", "-").ToLower(); } } if (db.pages.Where(x => x.Id != id).Any(x => x.Title == model.Title)) { ModelState.AddModelError("", "That title already exist"); return(View(model)); } else if (db.pages.Where(x => x.Id != id).Any(x => x.Slug == slug)) { ModelState.AddModelError("", "That slug already exist"); return(View(model)); } dTO.Slug = slug; dTO.Body = model.Body; dTO.HasSideBar = model.HasSideBar; db.SaveChanges(); } TempData["SM"] = "You have edited the page"; return(RedirectToAction("EditPage")); }
public ActionResult AddPage(PageVM model) { if (!ModelState.IsValid) { return(View(model)); } using (Db db = new Db()) { String slug; PageDTO dto = new PageDTO(); dto.Title = model.Title; if (string.IsNullOrWhiteSpace(model.Slug)) { slug = model.Title.Replace(" ", "-").ToLower(); } else { slug = model.Slug.Replace(" ", "-").ToLower(); } if (db.Pages.Any(x => x.Title == model.Title) || db.Pages.Any(x => x.Slug == slug)) { ModelState.AddModelError("", "That title or slug already exists"); return(View(model)); } dto.Slug = slug; dto.Body = model.Body; dto.HasSidebar = model.HasSidebar; dto.Sorting = 100; db.Pages.Add(dto); db.SaveChanges(); } TempData["SM"] = "Added a new Page !"; return(RedirectToAction("AddPage")); }
protected void Page_Load(object sender, EventArgs e) { //base.AllowHttpMethod("POST"); int ID = 0; int pgNow; int pgSize; int.TryParse(Request.Form["i"], out ID); int.TryParse(Request.Form["pgNow"], out pgNow); int.TryParse(Request.Form["pgSize"], out pgSize); DataSet ds = new DataSet(); using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString())) { using (SqlCommand cmd = new SqlCommand("dbo.usp_CodeM_xGetEnabledSystemCodeList", sc)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SystemCodeCateID", pgNow == 0 ? 1 : ID); cmd.Parameters.AddWithValue("@pgNow", pgNow == 0 ? 1 : pgNow); cmd.Parameters.AddWithValue("@pgSize", pgSize == 0 ? 10 : pgSize); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { sc.Open(); da.Fill(ds); } } } List <SystemCodeVM> list = new List <SystemCodeVM>(); PageVM rtn = new PageVM(); EntityS.FillModel(list, ds.Tables[0]); EntityS.FillModel(rtn, ds.Tables[1]); rtn.message = list; Response.ContentType = "application/json; charset=utf-8"; Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rtn)); Response.End(); }