public JsonResult AddItemToCart(int id, int count) { var item = _itemBusiness.GetById(id); var currentCart = Session["Cart"] as List <DTOCartItem>; if (currentCart.Any(i => i.Item.Id == item.Id)) { currentCart.FirstOrDefault(i => i.Item.Id == item.Id).Count += count; } else { var newCartItem = new DTOCartItem() { Item = item, Count = count }; currentCart.Add(newCartItem); } Session["Cart"] = currentCart; var result = GetCart(currentCart); return(Json(result, JsonRequestBehavior.AllowGet)); }