//TODO: return some ViewModel //TODO: make json send from modal in search public IActionResult Index() { (_cartService).Context = HttpContext; var products = _cartService.All(); IProduct[] enumerable = null; if (products.Count() != 0) { enumerable = products as IProduct[] ?? products.ToArray(); } var model = new CartViewModel() { Products = enumerable, TotalPrice = enumerable?.Sum(p => p.Price) ?? 0m, PromoCode = null }; return(View(model)); }