public ProductsWithTypesAndBrandsSpecification(ProductSpecParam 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(x => x.Price);
                    break;

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

                default:
                    AddOrderBy(x => x.Name);
                    break;
                }
            }
        }
Beispiel #2
0
 public ProuductsWithFilterCountSpec(ProductSpecParam 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 ProductWithFiltersForCountSpecification(ProductSpecParam productParameter) : base(x =>
                                                                                          (!productParameter.BrandId.HasValue || x.ProductBrandId == productParameter.BrandId) &&
                                                                                          (!productParameter.TypeId.HasValue || x.ProductTypeId == productParameter.TypeId) &&
                                                                                          (string.IsNullOrEmpty(productParameter.Search) || x.Name.ToLower().Contains(productParameter.Search))
                                                                                          )
 {
 }
 public ProductsWithFiltersForCountSpecification(ProductSpecParam specParams) :
     base(x =>
          (string.IsNullOrEmpty(specParams.Search) || x.Name.ToLower().Contains(specParams.Search)) &&
          (!specParams.BrandId.HasValue || x.ProductBrandId == specParams.BrandId) &&
          (!specParams.TypeId.HasValue || x.ProductTypeId == specParams.TypeId)
          )
 {
 }
 public ProductsWithBrandsAndTypesSpec(ProductSpecParam 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))
 {
     AddIncludes(x => x.ProductBrand);
     AddIncludes(x => x.ProducType);
     DecidingSortingOrder(productParams.Sort);
     AddPagination((productParams.PageSize * (productParams.PageIndex - 1)), productParams.PageSize);
 }
Beispiel #6
0
 public ProductsWithTypesAndBrandsSpecification(ProductSpecParam productParameter) : base(x =>
                                                                                          (!productParameter.BrandId.HasValue || x.ProductBrandId == productParameter.BrandId) &&
                                                                                          (!productParameter.TypeId.HasValue || x.ProductTypeId == productParameter.TypeId) &&
                                                                                          (string.IsNullOrEmpty(productParameter.Search) || x.Name.ToLower().Contains(productParameter.Search))
                                                                                          )
 {
     AddInclude(x => x.ProductBrand);
     AddInclude(x => x.ProductType);
     AddOrderBy(x => x.Name);
     ApplyPaging(productParameter.PageSize * (productParameter.PageIndex - 1), productParameter.PageSize);
 }
        public ProductswithBrandsAndTypes(ProductSpecParam 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))
        {
            AddIncludes(x => x.ProductType);
            AddIncludes(x => x.ProductBrand);
            OrderByAcse(x => x.Name);

            ApplyPaging(productParams.pageSize, (productParams.pageSize * (productParams.pageIndex - 1)));

            if (!String.IsNullOrWhiteSpace(productParams.Sort))
            {
                if (productParams.Sort == "priceAsc")
                {
                    OrderByAcse(x => x.Price);
                }
                else if (productParams.Sort == "priceDesc")
                {
                    OrderByDesc(x => x.Price);
                }
            }
        }