public ActionResult Index(GlobalSettingInfo info, int pageIndex = 1)
 {
     ActionResult ar=VerifyIfProjectSelected("PRJNAME");
     if (null != ar) return ar;
     this.GlobalSettingService.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_g"] ?? pageIndex;
     switch (requestKey)
     {
         case "query":
             return Query(info,1);
         case "edit":
             return Edit(info.SelectedGlobalSetting.Id, (int)pageindex);
         case "delete":
             return Delete(info.SelectedGlobalSetting.Id, (int)pageindex);
         case "save":
             return Save(info.SelectedGlobalSetting, (int)pageindex);
         default:
             Session["UpdatedId_g"] = null;
             Session["Log_g"] = null;
             return RedirectToAction("Index", new { pageIndex = (int)pageindex });
     }
 }
 private ActionResult Query(GlobalSettingInfo info, int pageIndex)
 {
     this.GlobalSettingService.CurrentProjectId = (int)Session["PID"];
     int recordCount;
     IEnumerable<GlobalSetting> globalSettings = this.GlobalSettingService.QueryGlobalSettings(info.QueryConditionEntity.Name, info.QueryConditionEntity.Value, pageIndex, PagingInfo.PageSize, out recordCount);
     Session["HasQueried_g"] = true;
     Session["QueriedPageIndex_g"] = pageIndex;
     Session["QueryConditionEntity"] = info.QueryConditionEntity;
     return RenderIndexView(globalSettings, recordCount, pageIndex);
 }
 private ActionResult RenderIndexView(IEnumerable<GlobalSetting> globalSettings, int recordCount, int pageIndex)
 {
     GlobalSettingInfo gsi = new GlobalSettingInfo { GlobalSettings = globalSettings,    SelectedGlobalSetting = new GlobalSetting(),
                                                          QueryConditionEntity = new QueryConditionEntity { Name = Nameof<GlobalSetting>.Property(gs => gs.Name), Value = Nameof<GlobalSetting>.Property(gs => gs.Value) }
                                                     };
     Func<int, UrlHelper, string> pageUrlAccessor = (currentPage, helper) => helper.RouteUrl("GlobalSettingPage", new { PageIndex = currentPage }).ToString();
     ViewResult result = View(gsi);
     ViewBag.RecordCount = recordCount;
     ViewBag.PageIndex = pageIndex;
     ViewBag.PageUrlAccessor = pageUrlAccessor;
     return result;
 }
 private ActionResult Edit(int gsid, int pageIndex)
 {
     Session["UpdatedId_g"] = gsid;
     if (null != Session["HasQueried_g"])
     {
         QueryConditionEntity qce = Session["QueryConditionEntity"] as QueryConditionEntity;
         GlobalSettingInfo info = new GlobalSettingInfo
         {   QueryConditionEntity =new QueryConditionEntity { Name = qce.Name, Value = qce.Value }};
         return Query(info, pageIndex);
     }
     return RedirectToAction("Index", new { pageIndex = pageIndex });
 }