コード例 #1
0
ファイル: BillsController.cs プロジェクト: bapinam/khoaluan
        public async Task <IActionResult> Index(string keyword, int pageIndex = 1, int pageSize = 3)
        {
            var request = new GetAllPaidBillPanning()
            {
                Keyword   = keyword,
                PageIndex = pageIndex,
                PageSize  = pageSize
            };
            var data = await _billApiClient.GetAllPaidBill(request);

            ViewBag.Keyword = keyword;

            return(View(data.ResultObj));
        }
コード例 #2
0
        public async Task <ApiResult <PagedResult <GetAllPaymentStautsBill> > > GetAllPaidBill(GetAllPaidBillPanning bundle)
        {
            IQueryable <Bill> bill;

            if (!string.IsNullOrEmpty(bundle.Keyword))
            {
                bill = _context.Bills.Include(x => x.BillDetails).Include(s => s.OrderPlan)
                       .Where(b => (b.StorageCode.Contains(bundle.Keyword) ||
                                    b.CodeBill.Contains(bundle.Keyword) || b.OrderPlan.Code.Contains(bundle.Keyword)) &&
                              b.PaymentStatus == PaymentStatus.Paid);
            }
            else
            {
                bill = _context.Bills.Include(x => x.BillDetails).Include(s => s.OrderPlan)
                       .Where(b => b.PaymentStatus == PaymentStatus.Paid);
            }

            bill = bill.Include(x => x.Creator);

            var result = await bill.OrderByDescending(x => x.Id).
                         Skip((bundle.PageIndex - 1) * bundle.PageSize)
                         .Take(bundle.PageSize)
                         .Select(x => new GetAllPaymentStautsBill()
            {
                Id          = x.Id,
                CodeBill    = x.CodeBill,
                StorageCode = x.StorageCode,
                CreatedDate = x.CreatedDate.ToString("dd-MM-yyyy"),
                CodePlan    = x.OrderPlan.Code,
                CodeCreator = x.Creator.Code
            }).ToListAsync();

            //3. Paging
            int totalRow = await bill.CountAsync();

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

            return(new ApiSuccessResult <PagedResult <GetAllPaymentStautsBill> >(pagedResult));
        }
コード例 #3
0
        public async Task <IActionResult> GetAllPaidBill([FromQuery] GetAllPaidBillPanning bundle)
        {
            var result = await _billService.GetAllPaidBill(bundle);

            return(Ok(result));
        }
コード例 #4
0
ファイル: BillApiClient.cs プロジェクト: bapinam/khoaluan
        public async Task <ApiResult <PagedResult <GetAllPaymentStautsBill> > > GetAllPaidBill(GetAllPaidBillPanning bundle)
        {
            var url = $"/api/Bill/paging?pageIndex=" +
                      $"{bundle.PageIndex}&pageSize={bundle.PageSize}&keyword={bundle.Keyword}";
            var result = await GetListAsync <GetAllPaymentStautsBill>(url);

            return(result);
        }