コード例 #1
0
        public async Task <IActionResult> Index(string keyword, int pageIndex = 1, int pageSize = 1)
        {
            var request = new GetProductTypeGroupPagingRequest()
            {
                Keyword   = keyword,
                PageIndex = pageIndex,
                PageSize  = pageSize
            };
            var data = await _productTypeGroupApiClient.GetUsersPaging(request);

            ViewBag.Keyword = keyword;

            return(View(data.ResultObj));
        }
コード例 #2
0
        public async Task <IActionResult> GetAllPaging([FromQuery] GetProductTypeGroupPagingRequest request)
        {
            var result = await _productTypeGroupService.GetUsersPaging(request);

            return(Ok(result));
        }
コード例 #3
0
        public async Task <ApiResult <PagedResult <ProductTypeGroupViewModel> > > GetUsersPaging(GetProductTypeGroupPagingRequest bundle)
        {
            IQueryable <ProductTypeGroup> query = _context.ProductTypeGroups;

            if (!string.IsNullOrEmpty(bundle.Keyword))
            {
                query = query.Where(c => c.Name.Contains(bundle.Keyword) || c.Code.Contains(bundle.Keyword));
            }
            //3. Paging
            int totalRow = await query.CountAsync();

            query = query.OrderByDescending(c => c.Id);
            var data = await query.Skip((bundle.PageIndex - 1) *bundle.PageSize)
                       .Take(bundle.PageSize)
                       .Select(i => new ProductTypeGroupViewModel()
            {
                Id   = i.Id,
                Code = i.Code,
                Name = i.Name
            }).ToListAsync();

            //4. Select and projection
            var pagedResult = new PagedResult <ProductTypeGroupViewModel>()
            {
                TotalRecords = totalRow,
                PageIndex    = bundle.PageIndex,
                PageSize     = bundle.PageSize,
                Items        = data
            };

            return(new ApiSuccessResult <PagedResult <ProductTypeGroupViewModel> >(pagedResult));
        }
コード例 #4
0
        public async Task <ApiResult <PagedResult <ProductTypeGroupViewModel> > > GetUsersPaging(GetProductTypeGroupPagingRequest bundle)
        {
            var url = $"/api/ProductTypeGroup/paging?pageIndex=" +
                      $"{bundle.PageIndex}&pageSize={bundle.PageSize}&keyword={bundle.Keyword}";
            var result = await GetListAsync <ProductTypeGroupViewModel>(url);

            return(result);
        }