Beispiel #1
0
        public IEnumerable <LeftNav> GetLeftNavsWithPagingAndSorting(int pageSize, int pageNumber, string orderBy, bool sort, string search)
        {
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "Id";
            }

            IEnumerable <LeftNav>       leftNavs   = null;
            IOrderedQueryable <LeftNav> queryOrder = null;

            if (sort)
            {
                queryOrder = _utils.OrderBy(_context.LeftNavs, orderBy);
            }
            else
            {
                queryOrder = _utils.OrderByDescending(_context.LeftNavs, orderBy);
            }

            if (string.IsNullOrEmpty(search))
            {
                leftNavs = queryOrder
                           .Skip((pageNumber - 1) * pageSize)
                           .Take(pageSize).Include(c => c.Childs).ToList();
            }
            else
            {
                leftNavs = queryOrder
                           .Where(p => p.Name.Contains(search) || p.Url.Contains(search))
                           .Skip((pageNumber - 1) * pageSize)
                           .Take(pageSize).Include(c => c.Childs).ToList();
            }


            return(leftNavs);
        }
Beispiel #2
0
        public IEnumerable <Project> GetProjectsWithPaging(int pageSize, int pageNumber, string orderBy, bool sort, string search)
        {
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "Id";
            }

            IEnumerable <Project>       projects   = null;
            IOrderedQueryable <Project> queryOrder = null;

            if (sort)
            {
                queryOrder = _utils.OrderBy(_context.Projects, orderBy);
            }
            else
            {
                queryOrder = _utils.OrderByDescending(_context.Projects, orderBy);
            }

            if (string.IsNullOrEmpty(search))
            {
                projects = queryOrder
                           .Skip((pageNumber - 1) * pageSize)
                           .Take(pageSize).ToList();
            }
            else
            {
                projects = queryOrder
                           .Where(p => p.Name.Contains(search))
                           .Skip((pageNumber - 1) * pageSize)
                           .Take(pageSize).ToList();
            }


            return(projects);
        }
        public IEnumerable <ApplicationUser> GetUsersWithPagingAndSorting(int pageSize, int pageNumber, string orderBy, bool sort, string search)
        {
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "Id";
            }

            IEnumerable <ApplicationUser>       users      = null;
            IOrderedQueryable <ApplicationUser> queryOrder = null;

            if (sort)
            {
                queryOrder = _utils.OrderBy(_userManager.Users, orderBy);
            }
            else
            {
                queryOrder = _utils.OrderByDescending(_userManager.Users, orderBy);
            }

            if (string.IsNullOrEmpty(search))
            {
                users = queryOrder
                        .Skip((pageNumber - 1) * pageSize)
                        .Take(pageSize).ToList();
            }
            else
            {
                users = queryOrder
                        .Where(p => p.UserName.Contains(search) || p.Email.Contains(search))
                        .Skip((pageNumber - 1) * pageSize)
                        .Take(pageSize).ToList();
            }


            return(users);
        }