public async Task <PageModelDto <ShelfDto> > GetPagedAsync(ShlefSearchDto search) { var total = await _shelfRepo.CountAsync(x => true); if (total == 0) { return new PageModelDto <ShelfDto> { TotalCount = 0 , PageIndex = search.PageIndex , PageSize = search.PageSize , PageCount = 0 } } ; var products = _productRepo.GetAll(); var shelfs = _shelfRepo.GetAll(); var skipNumber = (search.PageIndex - 1) * search.PageSize; var data = await(from s in shelfs join p in products on s.Id equals p.ShlefId into sp from x in sp.DefaultIfEmpty() select new ShelfDto() { Id = s.Id , FreezedQty = s.FreezedQty //, //Position = _mapper.Map<ShelfPositionDto>(s.Position) , ProductId = s.ProductId , ProductName = x.Name , ProductSku = x.Name , Qty = s.Qty }) .Skip(skipNumber) .Take(search.PageSize) .OrderByDescending(x => x.Id) .ToArrayAsync(); return(new PageModelDto <ShelfDto>() { PageIndex = search.PageIndex , PageSize = search.PageSize , TotalCount = total , Data = data }); }
public async Task <PageModelDto <ShelfDto> > GetPagedAsync([FromQuery] ShlefSearchDto search) { return(await _shelfSrv.GetPagedAsync(search)); }