public ActionResult Add(int?productID) { // then didnt come from products page if (productID == null) { return(RedirectToAction("Index")); // send them there } // used to send current qunatity to the page string sessionID = System.Web.HttpContext.Current.Session.SessionID; ShoppingCartRepo cartRepo = new ShoppingCartRepo(); ProductVisit cartItem = cartRepo.GetCartItem(sessionID, (int)productID); ProductVM productVM; if (cartItem == null) { ProductRepo pRepo = new ProductRepo(); Product product = pRepo.GetProduct(productID); productVM = new ProductVM(product); productVM.SetTotalCost(); // quntity times price productVM.image = product.Image.imageTitle; productVM.quantity = 1; } else { productVM = new ProductVM(cartItem.Product); productVM.SetTotalCost(); // quntity times price productVM.image = cartItem.Product.Image.imageTitle; productVM.quantity = cartItem.qtyOrdered; } return(View(productVM)); }