//______________________________________________________________________________________ /// <summary> /// Product/Cart /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult IncrementQuantityFront(int id) { try { ShoppingCartImplementation.AddToCart(id, @User.Identity.Name); return(RedirectToAction("Index", "Product")); } catch (Exception ex) { return(RedirectToAction("Index", "Product")); } }
//______________________________________________________________________________________ /// <summary> /// Product/Cart /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult IncrementQuantityFront(int id) { try { ShoppingCartImplementation.AddToCart(id, @User.Identity.Name); return(RedirectToAction("Index", "Product")); } catch (Exception ex) { bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy"); if (rethrow) { throw; } return(RedirectToAction("Index", "Product")); } }
//TESTING ITEMS ADDED TO CART WHEN THE QUANTITY INCREASES. public void AddToCartTest() { string UserId = "ashaka"; List <AddToCartModel> list = new List <AddToCartModel>(); list = ShoppingCartImplementation.GetFromCart(UserId); int pid = 5; int quantity = GetQuantityFromId(pid, list); string actual; actual = ShoppingCartImplementation.AddToCart(pid, UserId); List <AddToCartModel> list1 = new List <AddToCartModel>(); list1 = ShoppingCartImplementation.GetFromCart(UserId); int x = GetQuantityFromId(pid, list1); Assert.AreEqual(x, quantity + 1); }