public void NestedEachLoopsTest() { var pageList = new PageListModel() { Items = new List<PageModel>() { new PageModel() {Title = "A", Headline="B" }, new PageModel() {Title = "C", Headline="D" }, new PageModel() {Title = "E", Headline="F" } } }; ShouldRender("NestedEachLoopsTest1", pageList, "ABCDEF"); ShouldRender("NestedEachLoopsTest2", pageList, "ACE"); ShouldRender("NestedEachLoopsTest3", pageList, "BDF"); ShouldRender("NestedEachLoopsTest4", pageList, "AB"); ShouldRender("NestedEachLoopsTest5", pageList, "A"); ShouldRender("NestedEachLoopsTest6", pageList, "00A1B10C1D20E1F"); }
public override ActionResult Index(PageListBlock currentBlock) { var pages = FindPages(currentBlock); pages = Sort(pages, currentBlock.SortOrder); if (currentBlock.Count > 0) { pages = pages.Take(currentBlock.Count); } var model = new PageListModel(currentBlock) { Pages = pages }; ViewData.GetEditHints <PageListModel, PageListBlock>() .AddConnection(x => x.Heading, x => x.Heading); return(PartialView(model)); }
public ActionResult GrantPermission(PageListModel model) { //3x3 me first number pagename id and second number is roleId var s = new Dictionary <int, string>(); var role = Services.RoleService.GetAll(); //var role = db.Result<List<RoleModel>>("api/role/getAllForPagePermission?companyId=" + CompanyId, "", db.get); s = Processing(model, role); var list = new List <PagePermissionModel>(); foreach (var first in role) { foreach (var second in s) { if (first.Id == second.Key) { var ls = second.Value.Split('#'); foreach (var i in ls) { var newmodel = new PagePermissionModel(); if (i != "") { newmodel.RoleId = first.Id; newmodel.PageId = Int32.Parse(i); newmodel.IsActive = true; newmodel.IsAdminPage = model.IsAdminPage; newmodel.PageAction = newmodel.RoleId.ToString() + "x" + newmodel.PageId.ToString(); list.Add(newmodel); } } } } } Services.RoleService.SetGrantPermission(list); // var model1 = db.Result<List<CompanyPageModel>>("api/role/setGrantPermission?companyId=" + CompanyId, list, db.post); // TempData["Success"] = msg.Success; return(RedirectToAction("Index", "Role")); }
public PagedListData <List <SysLoginLog> > GetListByQuery(QueryLoginLogModel query) { var model = new PageListModel() { WithColumn = @"[Id] ,[AccessChannelId] ,[UserId] ,[UserName] ,[LogDate] ,[Token] ,[LogOutDate] ,[ClientIpAddress] ,[ClientName] ,[OnlineDate] ,[IsSucceed] ,[LogReason] ,[SessionId] ,[InUserType] ,[IPNum] ,[Enabled] ,[DelUser] ,[DelState] ,[DelDate]", WithWhere = " 1=1", LeftColumn = string.Empty, LeftJoin = string.Empty, }; var pageSearch = new PageSearch() { OrderBy = " LogDate desc", PageIndex = query.PageIndex, PageSize = query.PageSize, Where = query.Where }; return(this.PagedListQuery(model, pageSearch)); }
/// <summary> /// Page Action Result /// </summary> /// <returns></returns> public ActionResult Pages(int?page, int?sortColumnIndex, int?sortDirection) { PageListModel model = new PageListModel(); SearchAttributes searchParam = new SearchAttributes(); searchParam.CurrentPageNumber = (page.HasValue && page.Value > 0) ? page.Value : 1; searchParam.RecordsPerPage = AppSettingsUtility.GetInt(AppSettingsKeys.RecordsPerPage); searchParam.SortColumnIndex = 1; searchParam.SortDirection = (sortDirection.HasValue && sortDirection.Value == 1) ? Entity.SortDirection.Descending : Entity.SortDirection.Ascending; model.Populate(searchParam); //for Ajax Specific Request if (Request.IsAjaxRequest()) { return(View("~/Views/Shared/PartialViews/Admin/Page/_PageList.cshtml", model)); } else { return(View("~/Views/Admin/Page/PageList.cshtml", model)); } }
public async Task <IActionResult> Index(ProductAttributeFilterModel filter) { var productAttributePageList = await _productAttributeService.GetAsync(new ProductAttributeFilter { Page = filter.Page, PageSize = _pagerOptions.PageSize, Keyword = filter.Search, CanGetInactived = true, StatusId = filter.StatusId }); var productAttributes = productAttributePageList.Collections.Select(x => new ProductAttributeModel { Id = x.Id, Description = x.Description, Name = x.Name, CreatedById = x.CreatedById, UpdatedById = x.UpdatedById, CreatedDate = x.CreatedDate, UpdatedDate = x.UpdatedDate, StatusId = (ProductAttributeStatus)x.StatusId, UpdatedBy = x.UpdatedBy, CreatedBy = x.CreatedBy }); var productAttributePage = new PageListModel <ProductAttributeModel>(productAttributes) { Filter = filter, TotalPage = productAttributePageList.TotalPage, TotalResult = productAttributePageList.TotalResult }; if (_httpHelper.IsAjaxRequest(Request)) { return(PartialView("Partial/_ProductAttributeTable", productAttributePage)); } return(View(productAttributePage)); }
public async Task <IActionResult> Index(ShortcutFilterModel filter) { var shortcutPageList = await _shortcutService.GetAsync(new ShortcutFilter { Page = filter.Page, PageSize = _pagerOptions.PageSize, Keyword = filter.Search, TypeId = filter.TypeId, CanGetInactived = true, StatusId = filter.StatusId }); var shortcuts = shortcutPageList.Collections.Select(x => new ShortcutModel { Description = x.Description, Id = x.Id, Name = x.Name, Icon = x.Icon, TypeId = (ShortcutType)x.TypeId, Url = x.Url, Order = x.Order, StatusId = (ShortcutStatus)x.StatusId, }); var shortcutPage = new PageListModel <ShortcutModel>(shortcuts) { Filter = filter, TotalPage = shortcutPageList.TotalPage, TotalResult = shortcutPageList.TotalResult }; if (_httpHelper.IsAjaxRequest(Request)) { return(PartialView("Partial/_ShortcutTable", shortcutPage)); } return(View(shortcutPage)); }
public async Task <IActionResult> Index(RoleFilterModel filter) { var rolePageList = await _roleService.GetAsync(new RoleFilter { Page = filter.Page, PageSize = _pagerOptions.PageSize, Keyword = filter.Search }); var roleModels = rolePageList.Collections.Select(x => new RoleModel { CreatedById = x.CreatedById, CreatedByName = x.CreatedByName, CreatedDate = x.CreatedDate, UpdatedById = x.UpdatedById, UpdatedDate = x.UpdatedDate, UpdatedByName = x.UpdatedByName, Description = x.Description, Id = x.Id, Name = x.Name }); var rolePage = new PageListModel <RoleModel>(roleModels) { Filter = filter, TotalPage = rolePageList.TotalPage, TotalResult = rolePageList.TotalResult }; if (_httpHelper.IsAjaxRequest(Request)) { return(PartialView("_RoleTable", rolePage)); } return(View(rolePage)); }
public ActionResult PageList() { return(View("PageList", PageListModel.Get())); }
public void FilterByPageList() { PageListModel <UserEntity> page = new PageListModel <UserEntity>(); var res = UserService.Instance.Filter(page); }
public virtual PageListModel <T> Filter(PageListModel <T> info) { return(BaseCrudDao.Filter(info)); }
public PageListModel <UserEntity> GetAll([FromQuery] PageListModel <UserEntity> info) { var res = UserService.Instance.Filter(info); return(res); }
/// <summary> /// 分页 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="info"></param> /// <returns></returns> public PageListModel <T> Filter <T>(PageListModel <T> info) { using (var db = new SqlConnection(ConnectionStr)) { var sqlCount = new StringBuilder(); sqlCount.Append("SELECT count(1) FROM " + info.Table); var sql = new StringBuilder(); sql.Append("SELECT " + info.Field + " FROM " + info.Table); var where = new StringBuilder(); if (!info.WhereCol.IsStringEmpty() && !info.WhereVal.IsStringEmpty()) { var fildn = info.WhereCol.Trim().ToLower(); if (fildn.Contains(".")) { fildn = fildn.Split('.')[1]; } info.WhereVal = info.WhereVal.Trim(); switch (info.WhereCon) { //等于 case "0": where.Append(" AND " + info.WhereCol.EvalSqlString() + "='" + info.WhereVal.EvalSqlString() + "'"); break; //包含 case "1": where.Append(" AND " + info.WhereCol.EvalSqlString() + " LIKE '%" + info.WhereVal.EvalSqlString() + "%' "); break; //开始于 case "2": where.Append(" AND " + info.WhereCol.EvalSqlString() + " LIKE '" + info.WhereVal + "%'"); break; //结束于 case "3": where.Append(" AND " + info.WhereCol.EvalSqlString() + " LIKE '%" + info.WhereVal + "'"); break; //不包含 case "4": where.Append(" AND " + info.WhereCol.EvalSqlString() + " NOT LIKE '%" + info.WhereVal.EvalSqlString() + "%' "); break; //大于 case "5": where.Append(" AND " + info.WhereCol.EvalSqlString() + ">'" + info.WhereVal.EvalSqlString() + "'"); break; //大于等于 case "6": where.Append(" AND " + info.WhereCol.EvalSqlString() + ">='" + info.WhereVal.EvalSqlString() + "'"); break; //小于 case "7": where.Append(" AND " + info.WhereCol.EvalSqlString() + "<'" + info.WhereVal.EvalSqlString() + "'"); break; //小于等于 case "8": where.Append(" AND " + info.WhereCol.EvalSqlString() + "<='" + info.WhereVal.EvalSqlString() + "'"); break; //介于 case "9": where.Append(" AND " + info.WhereCol.EvalSqlString() + " BETWEEN '" + info.WhereVal.EvalSqlString() + "' AND '" + info.WhereVal1.EvalSqlString() + "'"); break; default: break; } } if (info.PageIndex == 0) { info.PageIndex = 1; } if (!info.WhereStr.IsStringEmpty()) { where.Append(" AND " + info.WhereStr); } var tempWhere = where.ToString().Trim().TrimStart("AND".ToCharArray()); if (!string.IsNullOrWhiteSpace(tempWhere)) { sqlCount.Append(" WHERE " + tempWhere); sql.Append(" WHERE " + tempWhere); } if (!info.GroupBy.IsStringEmpty()) { sql.Append(" GROUP BY " + info.GroupBy); } if (info.IsGetCount) { info.Count = !info.GroupBy.IsStringEmpty() ? db.ExecuteScalar <int>(string.Format("SELECT COUNT(1) FROM({0})as tmp", sql.ToString())) : db.ExecuteScalar <int>(sqlCount.ToString(), info); } if (info.OrderBy.IsStringEmpty()) { if (!info.Order.IsStringEmpty() && !info.Sort.IsStringEmpty()) { info.OrderBy = info.Sort + " " + info.Order; } else { info.OrderBy = info.Primary + " DESC"; } } sql.Append(" ORDER BY " + info.OrderBy); if (info.IsPage) { info.PageCount = info.PageSize == 0 ? 0 : Math.Ceiling(info.Count.ToDecimal() / info.PageSize.ToDecimal()).ToInt(); sql.Append(" OFFSET @Offset ROWS FETCH NEXT @Limit ROWS ONLY "); if (info.Offset.ToInt() <= 0) { info.Offset = (info.PageIndex - 1) * info.PageSize; } if (info.Limit.ToInt() <= 0) { info.Limit = info.PageSize; } } var s = sql.ToString(); info.List = db.Query <T>(sql.ToString(), info).ToList(); return(info); } }
public async Task <ActionResult> Configure(string id) { ActionResult result = null; if (id.Equals("Users", System.StringComparison.CurrentCultureIgnoreCase)) { var model = new UserListModel(); (await Users.GetUsers()).ForEach(i => { model.Users.Add(new UserModel() { Enabled = i.Enabled, Name = i.Name, FirstName = i.FirstName, LastName = i.LastName, Username = i.Username, Email = i.Email, Role = i.Role, Gravatar = i.Gravatar, Theme = i.Theme }); }); (await Roles.GetRoles()).ForEach(i => { model.Roles.Add(new RoleModel() { Name = i.Name, Builtin = i.Builtin }); }); result = View("Users", model); } if (id.Equals("Roles", System.StringComparison.CurrentCultureIgnoreCase)) { var model = new RoleListModel(); (await Roles.GetRoles()).ForEach(i => { model.Roles.Add(new RoleModel() { Name = i.Name, Builtin = i.Builtin }); }); result = View("Roles", model); } if (id.Equals("Pages", System.StringComparison.CurrentCultureIgnoreCase)) { var model = new PageListModel(); (await Pages.GetPages()).ForEach(i => { model.Pages.Add(new PageModel() { Group = i.Group, Name = i.Name, Url = i.Url, AbsoluteUrl = string.Format("{0}://{1}:{2}{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, i.Url.Replace("/", "/?")) }); }); result = View("Pages", model); } if (id.Equals("Groups", System.StringComparison.CurrentCultureIgnoreCase)) { var model = new GroupListModel(); (await Groups.GetGroups()).ForEach(i => { model.Groups.Add(new GroupModel() { Name = i.Name, Builtin = i.Builtin }); }); result = View("Groups", model); } if (id.Equals("Authorization", System.StringComparison.CurrentCultureIgnoreCase)) { var model = new PolicyListModel(); (await Roles.GetRoles()).ForEach(i => { model.Roles.Add(new RoleModel() { Name = i.Name, Builtin = i.Builtin }); }); (await Groups.GetGroups()).ForEach(i => { model.Groups.Add(new GroupModel() { Name = i.Name, Builtin = i.Builtin }); }); (await Policies.GetPolicies()).ForEach(i => { model.Policies.Add(new PolicyModel() { Role = i.Role, Group = i.Group, Effect = i.Effect ? "ALLOW" : "DENY" }); }); result = View("Authorization", model); } return(result); }
public async Task <IViewComponentResult> InvokeAsync(PageListModel paging) { return(await Task.FromResult(View(paging))); }