Ejemplo n.º 1
0
        public ProductsWithTypesAndBrandsSpecification(ProductsSpecParams prodParams) :
            base(x =>
                 (!prodParams.BrandId.HasValue || x.ProductBrandId == prodParams.BrandId) &&
                 (!prodParams.TypeId.HasValue || x.ProductTypeId == prodParams.TypeId) &&
                 (String.IsNullOrWhiteSpace(prodParams.search) || x.Name.Contains(prodParams.search)))
        {
            AddInclude(x => x.ProductType);
            AddInclude(x => x.ProductBrand);
            AddOrderBy(x => x.Name);
            ApplyPaging(prodParams.PageSize * (prodParams.PageIndex - 1), prodParams.PageSize);

            if (!String.IsNullOrWhiteSpace(prodParams.Sort))
            {
                switch (prodParams.Sort)
                {
                case "priceAsc":
                    AddOrderBy(p => p.Price);
                    break;

                case "priceDesc":
                    AddOrderByDesc(p => p.Price);
                    break;

                default:
                    AddOrderBy(n => n.Name);
                    break;
                }
            }
        }
 public ProductsWithFiltersForCountSpecification(ProductsSpecParams prodParams) :
     base(x =>
          (String.IsNullOrWhiteSpace(prodParams.search) || x.Name.Contains(prodParams.search)) &&
          (!prodParams.BrandId.HasValue || x.ProductBrandId == prodParams.BrandId) &&
          (!prodParams.TypeId.HasValue || x.ProductTypeId == prodParams.TypeId))
 {
 }
 public ProductWithFiltersForCountSpecification(ProductsSpecParams productParams)
     : base(x => (string.IsNullOrEmpty(productParams.Search) || x.Name.ToLower().Contains(productParams.Search)) && (!productParams.BrandId.HasValue || x.ProductBrandId == productParams.BrandId) && (!productParams.TypeId.HasValue || x.ProductTypeId == productParams.TypeId))
 {
 }