public async Task <KendoGrid <Goods> > Query(StockQueryDto dto)
        {
            var queryable = Context.Goods.Include(x => x.Category).AsQueryable();

            //.Skip(dto.Skip ?? 0)
            //.Take(dto.Take ?? int.MaxValue);
            if (dto.Id > 0)
            {
                queryable = queryable.Where(x => x.Id == dto.Id);
            }

            if (!string.IsNullOrEmpty(dto.Name))
            {
                queryable = queryable.Where(x => x.Name == dto.Name);
            }

            if (dto.CategoryId > 0)
            {
                queryable = queryable.Where(x => x.Category.Id == dto.CategoryId);
            }

            var count = await queryable.CountAsync();

            var result = await queryable.Skip(dto.Skip ?? 0).Take(dto.Take ?? 0).ToListAsync();

            var grid = new KendoGrid <Goods>(result, count);

            return(grid);
        }
        public ListResultDto <StockListDto> GetAll(StockQueryDto request)
        {
            var query = this.stockRepository.GetAll()
                        .Where(r => r.Amount != 0)
                        .WhereIf(!string.IsNullOrWhiteSpace(request.ProductName)
                                 , r => r.Product.Name.Contains(request.ProductName))
                        .WhereIf(!string.IsNullOrWhiteSpace(request.Code)
                                 , r => r.Product.Code.Contains(request.Code));

            query = !string.IsNullOrWhiteSpace(request.Sorting)
                ? query.OrderBy(request.Sorting)
                : query.OrderBy(r => r.Product.Name);
            var count = query.Count();
            var list  = query.AsQueryable().PageBy(request).ToList();
            var dtos  = list.MapTo <List <StockListDto> >();

            return(new PagedResultDto <StockListDto>(count, dtos));
        }