Ejemplo n.º 1
0
        public async Task <PagedResult <OrderDetailsVm> > Details(GetOrderDetailsPagingRequest request)
        {
            var data = await GetAsync <PagedResult <OrderDetailsVm> >(
                $"/api/orders/paging?pageIndex={request.PageIndex}" +
                $"&pageSize={request.PageSize}" +
                $"&keyword={request.Keyword}&categoryId={request.OrderId}&id={request.Id}");

            return(data);
        }
Ejemplo n.º 2
0
        public async Task <PagedResult <OrderDetailsVm> > GetAllDetails(GetOrderDetailsPagingRequest request)
        {
            var query = from p in _context.odersDetails
                        join pt in _context.products on p.idProduct equals pt.idProduct

                        select new { p, pt };

            //2. filter
            if (!string.IsNullOrEmpty(request.Keyword))
            {
                query = query.Where(x => x.p.idOder.Contains(request.Keyword));
            }
            //3. Paging
            int totalRow = await query.CountAsync();


            var data = await query.Skip((request.PageIndex - 1) *request.PageSize)
                       .Take(request.PageSize)
                       .Select(x => new OrderDetailsVm()
            {
                idOrderList = x.p.idOrderList,
                idOder      = x.p.idOder,
                idProduct   = x.p.idProduct,
                quatity     = x.p.quality,
                photoReview = x.pt.photoReview.Substring(22)
            }).ToListAsync();

            var pagedResult = new PagedResult <OrderDetailsVm>()
            {
                TotalRecords = totalRow,
                PageSize     = request.PageSize,
                PageIndex    = request.PageIndex,
                Items        = data
            };

            return(pagedResult);
        }