public IActionResult Post([FromBody] Cart model)
        {
            var res = _cartobj.AddCart(model);



            return(Ok(new { res }));
        }
        public async Task <ActionResult> AddToCart(int?color, Guid?productId, int qty)
        {
            var      objResponse = new ResponseObject();
            CartList cartList    = new CartList();

            if (productId != null)
            {
                ProductsBL objProduct = new ProductsBL();
                var        Product    = objProduct.GetProductDetail(productId);
                objProduct = null;

                if (Product != null)
                {
                    CartViewModel model = new CartViewModel();
                    model.ProductId = Product.Id;
                    model.SalePrice = Product.SalePrice;
                    string UserId = string.IsNullOrEmpty(Convert.ToString(User.Identity.Name)) ? string.Empty : User.Identity.Name;
                    var    user   = await UserManager.FindByNameAsync(UserId);

                    model.UserId = user.Id;
                    if (Session["sessionid"] == null)
                    {
                        Session["sessionid"] = Session.SessionID;
                    }
                    model.SessionId = Convert.ToString(Session["sessionid"]);
                    model.Qty       = qty;
                    CartBL obj = new CartBL();
                    Guid   Id  = obj.AddCart(model);
                    obj = null;

                    if (Id != null)
                    {
                        objResponse.IsSuccess   = "true";
                        objResponse.StrResponse = CommonFunction.SuccessMessage("Cart.", " Product added successfully.");
                        var list = this.RefreshList();
                        cartList.CartViewModelList = list;
                        cartList.Counter           = list.Count();
                    }

                    else
                    {
                        objResponse.IsSuccess   = "false";
                        objResponse.StrResponse = CommonFunction.ErrorMessage("Cart.", "Oops something went wrong.");
                    }
                }
                else
                {
                    objResponse.IsSuccess   = "false";
                    objResponse.StrResponse = CommonFunction.ErrorMessage("Cart.", "Product not found");
                }
            }
            else
            {
                string messages = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage));
                objResponse.IsSuccess   = "false";
                objResponse.StrResponse = CommonFunction.ErrorMessage(CommonMessagetype.TechnicalError.ToString(), CommonMessage.ErrorMessage);
            }
            return(Json(new
            {
                objResponse,
                html = this.RenderRazorViewToString("_miniCart", cartList),
            }, JsonRequestBehavior.AllowGet));
        }