Exemplo n.º 1
0
        public ICollection <T> Get(Expression <Func <T, bool> > filter = null, DataPagingOptions pagingOptions = null)
        {
            IQueryable <T> queryable = _dbContext.Set <T>();

            if (filter != null)
            {
                queryable = queryable.Where(filter);
            }

            if (pagingOptions?.PageSize > 0 && pagingOptions.PageNumber.GetValueOrDefault() > 0)
            {
                queryable = queryable
                            .Skip(pagingOptions.PageNumber.GetValueOrDefault() * pagingOptions.PageSize.GetValueOrDefault())
                            .Take(pagingOptions.PageSize.GetValueOrDefault());
            }

            return(queryable.ToList());
        }
        public SumResultModel <ProductListDto> GetProductList(Expression <Func <Products, bool> > filter = null, DataPagingOptions dataPagingOptions = null)
        {
            SumResultModel <ProductListDto> result = new SumResultModel <ProductListDto>();

            var list = _repository.Get(filter, dataPagingOptions).Select(c => new ProductListDto
            {
                ProductId       = c.ProductId,
                CategoryName    = c.CategoryId != null ? _baseCrudCategoryRepository.GetById((int)c.CategoryId).CategoryName : string.Empty,
                ProductName     = c.ProductName,
                QuantityPerUnit = c.QuantityPerUnit,
                SupplierName    = c.SupplierId != null ? _baseCrudSupplierRepository.GetById((int)c.SupplierId).CompanyName : string.Empty,
                UnitPrice       = c.UnitPrice,
                UnitsInStock    = c.UnitsInStock
            }).ToList();

            result.Data             = list;
            result.Success          = true;
            result.StatusCode       = 200;
            result.TotalRecordCount = _repository.GetTotalRecordCount();

            return(result);
        }
Exemplo n.º 3
0
 public ICollection <T> Get(Expression <Func <T, bool> > filter = null, DataPagingOptions pagingOptions = null)
 {
     return(_repository.Get(filter, pagingOptions));
 }