public ProductsWithTypesAndBrandsSpecification(ProductSpecParam productSpecParam) : base(x => (string.IsNullOrEmpty(productSpecParam.Search) || x.Name.ToLower().Contains(productSpecParam.Search)) && (!productSpecParam.BrandId.HasValue || x.ProductBrandId == productSpecParam.BrandId) && (!productSpecParam.TypeId.HasValue || x.ProductTypeId == productSpecParam.TypeId)) { AddInclude(a => a.ProductBrand); AddInclude(a => a.ProductType); AddOrderBy(a => a.Name); // default ApplyPaging(productSpecParam.PageSize * (productSpecParam.PageIndex - 1), productSpecParam.PageSize); if (!string.IsNullOrEmpty(productSpecParam.Sort)) { switch (productSpecParam.Sort) { case "priceAsc": AddOrderBy(a => a.Price); break; case "priceDesc": AddOrderByDescending(a => a.Price); break; default: AddOrderBy(a => a.Name); // default break; } } }
public ProductsWithFiltersForCountSpecification(ProductSpecParam productSpecParam) : base(x => (string.IsNullOrEmpty(productSpecParam.Search) || x.Name.ToLower().Contains(productSpecParam.Search)) && (!productSpecParam.BrandId.HasValue || x.ProductBrandId == productSpecParam.BrandId) && (!productSpecParam.TypeId.HasValue || x.ProductTypeId == productSpecParam.TypeId)) { }