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 ActionResult CreateRegisteredOrder(int[] goodId, string[] category, string ids = null, string ctgrs = null)
        {
            if (!string.IsNullOrEmpty(ids) && !string.IsNullOrEmpty(ctgrs))
            {
                goodId   = Array.ConvertAll(ids.Split(','), int.Parse);
                category = ctgrs.Split(',');
            }

            int i = 0;

            OrderValidators.UserName = User.Identity.Name;
            while (i < goodId.Length && i < category.Length)
            {
                OrderValidators.AllGoods = pcComponentsUnit.GetGoodsDependsOnCategory(category[i]);

                HttpCookie cookieReq = Request.Cookies["ShoppingBasket"];
                string     findItem  = string.Format($"{goodId[i]},{category[i]}+");

                if (cookieReq != null && cookieReq["ShoppingBasket"].Contains(findItem))
                {
                    Order order = OrdersManipulator.CreateAndReturnNewOrder(
                        User.Identity.Name,
                        pcComponentsUnit.GetGoodsDependsOnCategory(category[i]).FirstOrDefault(g => g.ID == goodId[i]),
                        OrderValidators.IsValidOrder);
                    if (order != null)
                    {
                        pcComponentsUnit.Orders.Create(order);
                        pcComponentsUnit.Save();
                        cookieReq["ShoppingBasket"] = cookieReq["ShoppingBasket"].Replace(findItem, "");
                        Response.Cookies.Add(cookieReq);
                        OrderInfoEvent($"Order({order.OrderId}) has been created and registered\nOwner name:{order.UserName}\n" +
                                       $"GoodId: {order.GoodId} Price: {order.GoodPrice}");
                    }
                }
                i++;
            }
            return(RedirectToActionPermanent("Orders"));
        }