예제 #1
0
        private FilterViewModelBase(PageSizeFilter pageSizeFilter, SortFilter sortFilter, PageFilter pageFilter)
        {
            this.PageSizeFilter = pageSizeFilter;
            this.SortFilter = sortFilter;
            this.PageFilter = pageFilter;

            this.Filters = new FilterList { pageSizeFilter, sortFilter, pageFilter };

            this.PageSize = new List<GenericFilterModelBase<int>>
                                {
                                    new GenericFilterModelBase<int> { Value = Constants.PageSizeDefault },
                                    new GenericFilterModelBase<int> { Value = Constants.PageSizeSmall },
                                    new GenericFilterModelBase<int> { Value = Constants.PageSizeBig }
                                };

            this.Sort = new List<GenericFilterModelBase<int>>
                            {
                                new GenericFilterModelBase<int>
                                    {
                                        Value = (int)(Core.Sort.PriceAsc),
                                        Name = Constants.PriceAsc
                                    },
                                new GenericFilterModelBase<int>
                                    {
                                        Value = (int)(Core.Sort.PriceDesc),
                                        Name = Constants.PriceDesc
                                    },
                                new GenericFilterModelBase<int>
                                    {
                                        Value = (int)(Core.Sort.RateDesc),
                                        Name = Constants.RateDesc
                                    }
                            };
            this.Pagging = new PagingViewModel(this.Category);
        }
예제 #2
0
 public FilterViewModelBase(string category, PageSizeFilter pageSizeFilter, SortFilter sortFilter, ProducersFilter producersFilter, PageFilter pageFilter, GroupFilter groupFilter)
     : this(pageSizeFilter, sortFilter, pageFilter)
 {
     this.ProducersFilter = producersFilter;
     this.GroupsFilter = groupFilter;
     this.Filters.Add(producersFilter);
     this.Filters.Add(groupFilter);
     this.Category = category;
 }
예제 #3
0
 public ActionResult Index(PageFilter pageFilter, SortFilter sortFilter, PageSizeFilter pageSizeFilter,
                           SearchFilter searchFilter)
 {
     var seperators = new[] {" ", "-"};
     string[] tokens = searchFilter.Keyword.Split(seperators, StringSplitOptions.RemoveEmptyEntries);
     ViewModel = new FilterViewModelBase(pageSizeFilter, sortFilter, pageFilter, searchFilter);
     expression = obj => tokens.All(t => obj.DisplayName.Contains(t));
     IEnumerable<Product> products = productRepository.GetProductWithProducersByExpression(expression);
     StartInitializeCommon(products.Count());
     EndInitializeCommon(products);
     return View(ViewModel);
 }
예제 #4
0
        public ActionResult Index(string category, PageSizeFilter pageSizeFilter, SortFilter sortFilter,
                                  ProducersFilter producerFilter, PageFilter pageFilter,
                                  [ModelBinder(typeof(GroupFilterBinder))] GroupFilter groupFilter)
        {
            try
            {
                var url = ProducerRedirect.GetUrl(Request.Url, category, producerFilter);
                if (url != string.Empty)
                {
                    return RedirectPermanent(url);
                }

                ViewModel = new FilterViewModelBase(category, pageSizeFilter, sortFilter, producerFilter, pageFilter,
                                                    groupFilter);

                var categoryObj = categoryRepository.Find(category);
                if (categoryObj == null)
                {
                    throw new Exception("Invalid category name.");
                }

                ViewModel.CategoryObj = categoryObj;
                IQueryable<Product> entities = productRepository.GetProductsWithProducerByProductName(category);
                entities = StartInitialize(entities);
                EndInitialize(entities);

                return View(ViewModel);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return RedirectToAction("index", "error", new { statusCode = 404 });
            }
        }
예제 #5
0
 public FilterViewModelBase(PageSizeFilter pageSizeFilter, SortFilter sortFilter, PageFilter pageFilter, SearchFilter searchFilter)
     : this(pageSizeFilter, sortFilter, pageFilter)
 {
     this.SearchFilter = searchFilter;
     this.Filters.Add(searchFilter);
 }