Ejemplo n.º 1
0
 public ProductWithFilterCountSpecification(ProductSpecParam param) : base(x =>
                                                                           (string.IsNullOrEmpty(param.Search) || x.Name.ToLower().Contains(param.Search)) &&
                                                                           (!param.BrandId.HasValue || x.ProductBrandId == param.BrandId) &&
                                                                           (!param.TypeId.HasValue || x.ProductTypeId == param.TypeId)
                                                                           )
 {
 }
Ejemplo n.º 2
0
        public ProductsWithTypesAndBrandsSpecification(ProductSpecParam param)
            : base(x =>
                   (string.IsNullOrEmpty(param.Search) || x.Name.ToLower().Contains(param.Search)) &&
                   (!param.BrandId.HasValue || x.ProductBrandId == param.BrandId) &&
                   (!param.TypeId.HasValue || x.ProductTypeId == param.TypeId)
                   )
        {
            AddInclude(x => x.ProductType);

            AddInclude(x => x.ProductBrand);

            AddOrderBy(x => x.Name);

            ApplyPaging(param.PageSize * (param.PageIndex - 1), param.PageSize);

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

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

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