예제 #1
0
        /// <summary>
        /// 分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <PageModelDto <WarehouseDto> > GetPagedAsync(WarehouseSearchDto search)
        {
            var total = await _warehouseRepo.CountAsync(x => true);

            if (total == 0)
            {
                return new PageModelDto <WarehouseDto>
                       {
                           TotalCount = 0
                           ,
                           PageIndex = search.PageIndex
                           ,
                           PageSize = search.PageSize
                       }
            }
            ;

            var products   = _productRepo.Where(x => true);
            var warehouses = _warehouseRepo.Where(x => true);

            var skipNumber = (search.PageIndex - 1) * search.PageSize;

            var data = await(from s in warehouses
                             join p in products
                             on s.ProductId equals p.Id into sp
                             from x in sp.DefaultIfEmpty()
                             select new WarehouseDto()
            {
                Id = s.Id.ToString()
                ,
                FreezedQty = s.BlockedQty
                ,
                PositionCode = s.Position.Code
                ,
                PositionDescription = s.Position.Description
                ,
                ProductId = s.ProductId.Value.ToString()
                ,
                ProductName = x.Name
                ,
                ProductSku = x.Sku
                ,
                Qty = s.Qty
            })
                       .Skip(skipNumber)
                       .Take(search.PageSize)
                       .OrderByDescending(x => x.Id)
                       .ToListAsync();

            return(new PageModelDto <WarehouseDto>()
            {
                PageIndex = search.PageIndex
                ,
                PageSize = search.PageSize
                ,
                TotalCount = total
                ,
                Data = data
            });
        }
예제 #2
0
    /// <summary>
    /// 分页列表
    /// </summary>
    /// <param name="search"></param>
    /// <returns></returns>
    public async Task <PageModelDto <WarehouseDto> > GetPagedAsync(WarehouseSearchDto search)
    {
        var total = await _warehouseRepo.CountAsync(x => true);

        if (total == 0)
        {
            return(new PageModelDto <WarehouseDto>(search));
        }

        var products   = _productRepo.Where(x => true);
        var warehouses = _warehouseRepo.Where(x => true);
        var data       = await(from s in warehouses
                               join p in products
                               on s.ProductId equals p.Id into sp
                               from x in sp.DefaultIfEmpty()
                               select new WarehouseDto()
        {
            Id                  = s.Id,
            FreezedQty          = s.BlockedQty,
            PositionCode        = s.Position.Code,
            PositionDescription = s.Position.Description,
            ProductId           = s.ProductId,
            ProductName         = x.Name,
            ProductSku          = x.Sku,
            Qty                 = s.Qty
        })
                         .Skip(search.SkipRows())
                         .Take(search.PageSize)
                         .OrderByDescending(x => x.Id)
                         .ToListAsync();

        return(new PageModelDto <WarehouseDto>(search, data, total));
    }
예제 #3
0
 public async Task <PageModelDto <WarehouseDto> > GetPagedAsync([FromQuery] WarehouseSearchDto search)
 {
     return(await _warehouseSrv.GetPagedAsync(search));
 }