public ProductWithBrandAndTypeSpecification(ProductSpecParams productParams) :
            base(x =>

                 (string.IsNullOrEmpty(productParams.Search) ||
                  x.Name.ToLower().Contains(productParams.Search)) &&
                 //BrandId = 2
                 (!productParams.BrandId.HasValue ||
                  x.ProductBrandId == productParams.BrandId)

                 && (!productParams.TypeId.HasValue || x.ProductTypeId == productParams.TypeId)

                 )
        {
            AddIncludes(x => x.ProductType);
            AddIncludes(x => x.ProductBrand);
            AddOrderBy(x => x.Name);

            // PageIndex = 3 ; Skip will be (6 * 2) = 12
            AddPaging(productParams.PageSize * (productParams.PageIndex - 1),
                      productParams.PageSize);

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

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

                default:
                    AddOrderBy(n => n.Name);
                    break;
                }
            }
        }
Beispiel #2
0
        public ProductsWithTypesAndBrandsSpecification(ProductSpecParams 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)
                   )
        {
            AddInclude(x => x.ProductType);
            AddInclude(x => x.ProductBrand);
            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 "priceDesc":
                    AddOrderByDescending(p => p.Price);
                    break;

                case "nameAsc":
                    AddOrderBy(p => p.Name);
                    break;

                case "nameDesc":
                    AddOrderByDescending(p => p.Name);
                    break;
                }
            }
        }
 public ProductWithFiltersForCountSpecification(ProductSpecParams 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))
 {
 }
 public ProductsWithFiltersForCountSpecification(ProductSpecParams productParams)
     : base(x =>
            (!productParams.BrandId.HasValue || x.ProductBrandId == productParams.BrandId) &&
            (!productParams.TypeId.HasValue || x.ProductTypeId == productParams.TypeId))
 {
 }
 public ProductWithTypeAndBrandSpecCount(ProductSpecParams productParams)
     : base(productParams)
 {
     IsPagingEnable = false;
 }