Пример #1
0
        public ProductWithFiltersForCountSPecification(ProductSpecParam productParams)
            : base(x =>
                   (!productParams.TypeId.HasValue || x.ProductTypeId == productParams.TypeId)

                   )
        {
        }
Пример #2
0
        public ProductsWithTypesSpecification(ProductSpecParam productParams)
            : base(x =>
                   (string.IsNullOrEmpty(productParams.Search) || x.Name.ToLower().Contains(productParams.Search)) &&
                   (!productParams.TypeId.HasValue || x.ProductTypeId == productParams.TypeId)

                   )
        {
            addInclude(x => x.ProductType);
            AddOrderBy(x => x.Name);
            // ApplyPaging(productParams.PageSize * (productParams.PageIndex - 1), productParams.PageSize);

            if (!string.IsNullOrEmpty(productParams.Sort))
            {
                switch (productParams.Sort)
                {
                case "priceAsc":
                    AddOrderBy(p => p.Price);
                    break;

                case "proceDesc":
                    AddOrderBy(p => p.Price);
                    break;

                default:
                    AddOrderBy(p => p.Name);
                    break;
                }
            }
        }