protected PageButtonVM[] Paging(int pageIndex, int count, string sessionKey, int pageSize = 3)
        {
            int pageCount = (int)Math.Ceiling((float)count / pageSize);

            if (pageIndex > pageCount - 1)
            {
                pageIndex = pageCount - 1;
            }


            Session[sessionKey] = pageIndex;


            PagingBuilder pb = new PagingBuilder();

            pb.PageCount     = pageCount;
            pb.PageIndex     = pageIndex + 1;
            pb.ItemTemplates = new string[] { "{0}", "javascript:onPagingButtonClick('{0}');" };
            pb.Mode          = new BalancedPagingMode()
            {
                FloatingItemCount = 3,
                TotalItemCount    = 12
            };

            return(pb.Build().Items.Select(i => new PageButtonVM()
            {
                ClassName = GetClassName(i),
                Text = i.Text,
                IsGap = i.IsGap,
                OnClick = string.Format("javascript:onPagingButtonClick({0})", int.Parse(i.Text) - 1)
            }).ToArray());
        }
Example #2
0
        public static IQueryable <T> ApplyQueryParams <T>(this IQueryable <T> queryable, QueryParams @params)
            where T : class
        {
            if (@params == null)
            {
                return(queryable);
            }

            IQueryBuilder <T> expandBuilder = new IncludeBuilder <T>();
            var result = expandBuilder.Build(@params, queryable);

            IQueryBuilder <T> filterBuilder = new QueryBuilder <T>();

            result = filterBuilder.Build(@params, result);

            IQueryBuilder <T> orderBuilder = new OrderByBuilder <T>();

            result = orderBuilder.Build(@params, result);

            IQueryBuilder <T> pagingBuilder = new PagingBuilder <T>();

            result = pagingBuilder.Build(@params, result);

            return(result);
        }