public JsonResult AddProduct(string pid) { AddToCartBean aBean = new AddToCartBean(); aBean.pid = pid; AddToCart.AddCart(aBean); return(Json(AddToCart.getCartNumberofItem(), JsonRequestBehavior.AllowGet)); }
public static List <AddToCartBean> AddCart(AddToCartBean addItem) { Page page = new Page(); List <AddToCartBean> aBeanList = null; try { aBeanList = (List <AddToCartBean>)page.Session["AddList"]; if (aBeanList == null) { aBeanList = new List <AddToCartBean>(); } if (!aBeanList.Contains(addItem)) { if (!aBeanList.Equals(addItem)) { addItem.TotalPrice = addItem.ProductQty * addItem.ProductPrice; aBeanList.Add(addItem); } } page.Session["AddList"] = aBeanList; } catch { if (!aBeanList.Contains(addItem)) { if (!aBeanList.Equals(addItem)) { addItem.TotalPrice = addItem.ProductQty * addItem.ProductPrice; aBeanList.Add(addItem); } } page.Session["AddList"] = aBeanList; } return(aBeanList); }