示例#1
0
        public static GridModel GetGridModel(PagerArgs args, string DefaultSortKey)
        {
            var gm = new GridModel
            {
                Pager = new GridPager
                {
                    Pages = new List <GridPage>()
                }
            };

            if (string.IsNullOrWhiteSpace(args.CurrentPage))
            {
                gm.Pager.CurrentPage = 1;
            }
            else
            {
                gm.Pager.CurrentPage = args.CurrentPage.IntParse();
            }

            if (string.IsNullOrWhiteSpace(args.PageSize))
            {
                gm.Pager.PageSize = 12;
            }
            else
            {
                gm.Pager.PageSize = args.PageSize.IntParse();
            }

            if (string.IsNullOrWhiteSpace(args.PagerCount))
            {
                gm.Pager.PagerCount = 5;
            }
            else
            {
                gm.Pager.PagerCount = args.PagerCount.IntParse();
            }

            if (string.IsNullOrWhiteSpace(args.SortKey))
            {
                gm.SortKey = DefaultSortKey;
            }
            else
            {
                gm.SortKey = args.SortKey;
            }

            if (string.IsNullOrWhiteSpace(args.SortDirection))
            {
                gm.SortDirection = "DESC";
            }
            else
            {
                gm.SortDirection = args.SortDirection;
            }

            return(gm);
        }
示例#2
0
    public static PagerData ApplyArgs <T>(this PagerArgs Args, IQueryable <T> candidates)
    {
        Args.RecordCount = candidates.Count();
        candidates       = candidates.Skip(Args.PageIndex * Args.PageSize).Take(Args.PageSize);
        PagerData data = new PagerData();

        data.PagerArgs = Args;
        try
        {
            data.Data = candidates.ToList();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        }
        return(data);
    }
示例#3
0
    public PagerArgs GetPagerArgs()
    {
        var x = new PagerArgs(Convert.ToInt32(this.RecordCount), Convert.ToInt32(this.CurrentPage), this.PageSize);

        return(x);
    }