// GET: Cart public ActionResult Index(int?id) { string userId = _shopRepository.GetUserByName(User.Identity.Name).Id; if (id != null) { _shopRepository.AddProductToCart(id, userId); } IList <Product> userProducts = _shopRepository.GetUserCart(userId); decimal totalPrice = userProducts.Sum(x => x.Price); ViewBag.TotalPrice = totalPrice; return(View(userProducts)); }