public ActionResult Index(ControlInfo info, int pageIndex = 1) { ActionResult ar = VerifyIfProjectSelected("PRJNAME"); if (null != ar) return ar; this.ControlService.CurrentProjectId = (int)Session["PID"]; string requestKey = Request.Form.Keys[Request.Form.Keys.Count - 1] as string; if (requestKey.Contains(".")) requestKey = requestKey.Substring(0, requestKey.IndexOf(".")); object pageindex = Session["QueriedPageIndex_c"] ?? pageIndex; switch (requestKey) { case "query": return Query(info,1); case "edit": return Edit(info.SelectedControl.Id,info.SelectedControl.ControlProperty.Type, (int)pageindex); case "delete": return Delete(info.SelectedControl.Id, (int)pageindex); case "save": return Save(info.SelectedControl, (int)pageindex); default: Session["UpdatedId_c"] = null; Session["Log_c"] = null; return RedirectToAction("Index", new { pageIndex = (int)pageindex }); } }
private ActionResult Query(ControlInfo info, int pageIndex) { this.ControlService.CurrentProjectId = (int)Session["PID"]; int recordCount; IEnumerable<Control> controls = this.ControlService.QueryControls(info.SearchedConditionEntity.ControlType, info.SearchedConditionEntity.ControlProperty, info.SearchedConditionEntity.PropertyValue, info.SearchedConditionEntity.ControlName, pageIndex, PagingInfo.PageSize, out recordCount); Session["HasQueried_c"] = true; Session["QueriedPageIndex_c"] = pageIndex; Session["SearchedConditionEntity"] = info.SearchedConditionEntity; return (Session["PropertyListWhenEdit"] == null) ? RenderIndexView(controls, null, recordCount, pageIndex) : RenderIndexView(controls, (IList<SelectListItem>)Session["PropertyListWhenEdit"], recordCount, pageIndex); }
private ActionResult RenderIndexView(IEnumerable<Control> controls, IList<SelectListItem> propertyListWhenEdit, int recordCount, int pageIndex) { ControlInfo ci = new ControlInfo { Controls = controls, PropertyListWhenEdit = propertyListWhenEdit??null, SearchedConditionEntity = new SearchedConditionEntity { ControlType = Nameof<Control>.Property(c => c.ControlProperty.Type), ControlProperty = Nameof<Control>.Property(c => c.ControlProperty.Property), PropertyValue = Nameof<Control>.Property(c => c.PropertyValue), ControlName = Nameof<Control>.Property(c => c.Name) } }; Func<int, UrlHelper, string> pageUrlAccessor = (currentPage, helper) => helper.RouteUrl("ControlPage", new { PageIndex = currentPage }).ToString(); ViewResult result = View(ci); ViewBag.RecordCount = recordCount; ViewBag.PageIndex = pageIndex; ViewBag.PageUrlAccessor = pageUrlAccessor; return result; }
private ActionResult Edit(int cid, string selectedType, int pageIndex) { Session["UpdatedId_c"] = cid; string selectedProperty = this.ControlService.GetControlPropertyById(cid); IEnumerable<string> properties = this.ControlService.GetControlPropertiesAgainstControlType(selectedType); Session["PropertyListWhenEdit"] = BindDropdownlist(properties, selectedProperty, false); if (null != Session["HasQueried_c"]) { SearchedConditionEntity sce = Session["SearchedConditionEntity"] as SearchedConditionEntity; ControlInfo ci = new ControlInfo { SearchedConditionEntity = sce, PropertyListWhenEdit = Session["PropertyListWhenEdit"] as IList<SelectListItem> }; return Query(ci,pageIndex); } return RedirectToAction("Index", new { pageIndex=pageIndex}); }