public IActionResult AddArticleToCart(int id) { string jsonCart = HttpContext.Session.GetString("cart"); Cart cart = (jsonCart == null) ? new Cart() : JsonConvert.DeserializeObject <Cart>(jsonCart); cart.AddArticleToCart(Article.GetArticleById(id)); HttpContext.Session.SetString("cart", JsonConvert.SerializeObject(cart)); string total = Convert.ToString(cart.Total); HttpContext.Session.SetString("Total", total); string nbArticles = Convert.ToString(cart.NbArticles); HttpContext.Session.SetString("NbArticles", nbArticles); return(RedirectToRoute(new { controller = "Cart", action = "UserCart" })); }