public ActionResult AddToCart(int productID) { // call the method and map the info to the productInfo ProductPO productInfo = _mapper.Map(_productDataAccess.ViewOneProduct(productID)); // create a new instance of cartPO CartPO _CheckOut = new CartPO(); // set correct values to the _checkOut _CheckOut.checkOutTotal = productInfo.productPrice; _CheckOut.productID = productID; _CheckOut.productQuantity = productInfo.productQuantity; _CheckOut.supplierID = productInfo.supplierID; _CheckOut.supplierName = productInfo.supplierName; _CheckOut.userTableID = (int)Session["userTableID"]; _CheckOut.checkOutQuantity = 1; _CheckOut.checkOutTax = 0.04M; _CheckOut.checkOutShipping = 10.00M; _CheckOut.checkOutDate = DateTime.Today; // map the info _cartDataAccess.CreateCart(_mapper.Map(_CheckOut)); // return to the view products view return(RedirectToAction("ViewProducts", "Product")); }
public ActionResult UpdateItemQuantity(CartPO item) { if (item.checkOutQuantity > item.productQuantity) { return(RedirectToAction("ViewCart", "Cart", new { userTableID = item.userTableID })); } else { // pass the id to the method then to the DAL _cartDataAccess.UpdateItemQuantity(item.checkOutID, item.checkOutQuantity, item.productID); } // return the view cart page return(RedirectToAction("ViewCart", "Cart", new { userTableID = item.userTableID })); }
public void ShouldBeAbleToCompletePurchase() { var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _driver = new FirefoxDriver(outPutDirectory); var InventoryPO = new InventoryPO(_driver); var CartPO = new CartPO(_driver); var CheckoutOnePO = new CheckoutOnePO(_driver); var CheckoutTwoPO = new CheckoutTwoPO(_driver); InventoryPO.Visit(); InventoryPO.addAllItemsToCart(); CartPO.confirmCart(); CheckoutOnePO.fillInformationForm("Andrei", "Gonçalves", "1109657"); CheckoutOnePO.submitForm(); CheckoutTwoPO.finishPurchase(); Assert.IsTrue(_driver.Url.Contains("checkout-complete.html")); }