public ActionResult ComponentsCatalog(string[] Brands, string returnUrl, CommonSort SortByIncreaseName = CommonSort.Нет, CommonSort SortByIncreasePrice = CommonSort.Нет, CommonSort SortByIncreaseProducedAt = CommonSort.Нет, string category = "Процессоры", int?minPrice = null, int?maxPrice = null, int page = 1, int pageSize = 20) { ViewBag.returnUrl = returnUrl; if (Session["CurrentFilter"] == null || ((PcComponentsFilter)Session["CurrentFilter"]).Category != category) { Session["CurrentFilter"] = new PcComponentsFilter(); } PcComponentsFilter curFilter = new PcComponentsFilter { SortByIncreaseName = SortByIncreaseName, SortByIncreasePrice = SortByIncreasePrice, SortByIncreaseProducedAt = SortByIncreaseProducedAt, MinPrice = minPrice, MaxPrice = maxPrice, Brands = Brands, Category = category }; if (curFilter.ValidateInputParameters()) { Session["CurrentFilter"] = curFilter; } else { ModelState.AddModelError("CatalogViewModel", curFilter.ErrorMessage); } IEnumerable <Good> allGoods = componentsUnit.GetGoodsDependsOnCategory(category); IEnumerable <Good> filteredGoods = componentsUnit.GetGoodsDependsOnFilter(category, (PcComponentsFilter)Session["CurrentFilter"]); if (allGoods != null && filteredGoods != null) { return(View(CatalogViewModel <Good> .GetCatalogViewModel(page, pageSize, filteredGoods, allGoods, category))); } throw new HttpException(404, "Page Not Found"); }
public IEnumerable <Good> GetGoodsDependsOnFilter(string category, PcComponentsFilter filter) { switch (category) { case "Процессоры": return(Processors.GetAll(filter)); case "Материнские платы": return(Motherboards.GetAll(filter)); case "Видеокарты": return(VideoCards.GetAll(filter)); case "Корпуса": return(ComputerСases.GetAll(filter)); case "Модули памяти": return(MemoryModules.GetAll(filter)); case "Блоки питания": return(PowerSupplies.GetAll(filter)); case "SSD диски": return(SSDDrives.GetAll(filter)); default: return(null); } }