public IActionResult Remove(int id)
        {
            List <CartItemViewModel> cart = CartSession.GetObjectFromJson <List <CartItemViewModel> >(HttpContext.Session, "cart");
            int index = isExist(id);

            cart.RemoveAt(index);
            CartSession.SetObjectAsJson(HttpContext.Session, "cart", cart);
            return(RedirectToAction("Index"));
        }
        public IActionResult Info()
        {
            List <CartItemViewModel> cart = CartSession.GetObjectFromJson <List <CartItemViewModel> >(HttpContext.Session, "cart");

            // int index = isExist(id);
            //List<CartItemViewModel> xuly= CartSession.GetObjectFromJson<List<CartItemViewModel>>(HttpContext.Session, "xuly");
            // xuly.Add(new CartItemViewModel { Id = 1.ToString(), Prod_ID = cart[1].Prod_ID, Prod_Name = cart[1].Prod_Name, Price = cart[1].Price, Quantity = cart[1].Quantity });
            // CartSession.SetObjectAsJson(HttpContext.Session, "xuly", cart);
            // List<CartItemViewModel> xu = CartSession.GetObjectFromJson<List<CartItemViewModel>>(HttpContext.Session, "xuly");
            // var u=  HttpContext.Session.GetString(SystemConstants.AppSettings.Token);
            //  LoginRequest user = CartSession.GetUser<LoginRequest>(HttpContext.Session, "Token");
            //User.Identity.Name;


            // cart.Clear();
            CartSession.SetObjectAsJson(HttpContext.Session, "cart", cart);
            return(View());
        }
        public async Task <IActionResult> Buy(int id)
        {
            var result = await _productApiClient.GetById(id);

            var a = result.ResultObj;
            ProductViewModel productModel = new ProductViewModel()
            {
                Prod_ID   = a.Prod_ID,
                Prod_Name = a.Prod_Name,
                Price     = a.Price,
                ImagePath = a.ImagePath
            };

            if (CartSession.GetObjectFromJson <List <CartItemViewModel> >(HttpContext.Session, "cart") == null)
            {
                List <CartItemViewModel> cart = new List <CartItemViewModel>();
                cart.Add(new CartItemViewModel {
                    Id = 1.ToString(), Prod_ID = productModel.Prod_ID, Prod_Name = productModel.Prod_Name, Price = productModel.Price, Quantity = 1, ImagePath = productModel.ImagePath
                });
                CartSession.SetObjectAsJson(HttpContext.Session, "cart", cart);
            }
            else
            {
                List <CartItemViewModel> cart = CartSession.GetObjectFromJson <List <CartItemViewModel> >(HttpContext.Session, "cart");
                int index = isExist(id);
                if (index != -1)
                {
                    cart[index].Quantity++;
                }
                else
                {
                    cart.Add(new CartItemViewModel {
                        Prod_ID = productModel.Prod_ID, Prod_Name = productModel.Prod_Name, Price = productModel.Price, Quantity = 1, ImagePath = productModel.ImagePath
                    });
                }
                CartSession.SetObjectAsJson(HttpContext.Session, "cart", cart);
            }
            return(RedirectToAction("Index"));
        }