public ActionResult Index(bool?afterBuy) { HttpCookie consumerBasketRawDataCookie = Request.Cookies["ConsumerBasket"]; ConsumerBasketViewModel consumerBasketViewModel = new ConsumerBasketViewModel(); consumerBasketViewModel.AfterBuy = afterBuy; if (consumerBasketRawDataCookie != null) { List <ProductInBasketViewModel> productInBasketViewModels = JsonConvert.DeserializeObject <List <ProductInBasketViewModel> >( HttpContext.Server.UrlDecode(consumerBasketRawDataCookie.Value)); List <Product> products = _productsBL.GetByIds(productInBasketViewModels.Select(x => x.Id)); consumerBasketViewModel.ProductToByDescriptors.AddRange(products.Select(product => { ProductInBasketViewModel productInBasketViewModel = productInBasketViewModels.Single(x => x.Id == product.Id); return(new ProductToBuyDescriptor { Product = product, Quantity = productInBasketViewModel.Quantity, CategoryId = productInBasketViewModel.CategoryId }); })); } return(View(consumerBasketViewModel)); }