public ActionResult Checkout(int[] quanti, double totalCheckout) { List <ProductForCart> cartItem = (List <ProductForCart>)Session["cart"]; try { var idUser = Session["idUser"]; //Lấy lại dữ liệu trong for (int i = 0; i < quanti.Length; i++) { cartItem[i].quantity = quanti[i]; } foreach (var item in cartItem) { Cart c = new Cart { price = item.price, quantity = item.quantity, id_product = item.Id, user_id = Convert.ToInt32(idUser), created_at = DateTime.Now, }; carts.Insert_Cart(c); } #region Checkout Checkout itemCheckout = new Checkout { id_user = Convert.ToInt32(idUser.ToString()), checkout_total = totalCheckout, created_at = DateTime.Now, }; checks.Add_Checkout(itemCheckout); #endregion } catch (Exception) { throw; } cartItem = new List <ProductForCart>(); Session["cart"] = null; return(Json(new { content = "" })); }