public async Task <IActionResult> QueryPaginAsync(SelectStockDto model)
        {
            var result = await _service.QueryPaginStockAsync(model);

            return(Ok(result));
        }
Exemplo n.º 2
0
        public async Task <ReturnPagin <List <ReturnStockDto> > > QueryPaginStockAsync(SelectStockDto model)
        {
            var result = new ReturnPagin <List <ReturnStockDto> >();
            var stocks = _context.Stocks.Include(i => i.Product).AsNoTracking();

            if (model.ProductId.HasValue)
            {
                stocks = stocks.Where(i => i.PrductId == model.ProductId);
            }
            result.Count = await stocks.CountAsync();

            result.Number = model.Number;
            result.Page   = model.Page;
            result.Items  = _mapper.Map <List <ReturnStockDto> >(await stocks.Pagin(model).ToListAsync());
            return(result);
        }