public ProductWithBrandsAndTypeSpecification(ProductSpecParameters ProductParam) : base(x => (string.IsNullOrEmpty(ProductParam.Search) || x.Name.ToLower().Contains(ProductParam.Search)) && (!ProductParam.BrandId.HasValue || x.ProductBrandId == ProductParam.BrandId) && (!ProductParam.TypeId.HasValue || x.ProductTypeId == ProductParam.TypeId) ) { Addincludes(x => x.ProductType); Addincludes(x => x.ProductBrand); AddOrderBy(x => x.Name); ApplyPaging(ProductParam.PageSize * (ProductParam.PageIndex - 1), ProductParam.PageSize); if (!string.IsNullOrEmpty(ProductParam.Sort)) { switch (ProductParam.Sort) { case "priceAsc": AddOrderBy(p => p.Price); break; case "priceDesc": AddOrderByDesc(p => p.Price); break; default: AddOrderBy(n => n.Name); break; } } }
public ProductWithFilterandCountSpecifications(ProductSpecParameters ProductParam) : base(x => (string.IsNullOrEmpty(ProductParam.Search) || x.Name.ToLower().Contains(ProductParam.Search)) && (!ProductParam.BrandId.HasValue || x.ProductBrandId == ProductParam.BrandId) && (!ProductParam.TypeId.HasValue || x.ProductTypeId == ProductParam.TypeId) ) { }