public PartialViewResult Summary() { cart = GetCart(); ViewBag.CountProduct = cart.Count().ToString(); ViewBag.TotalValue = ModifyCart.GetTotalValue(GetCart()); return(PartialView()); }
public async Task <IActionResult> Index(string returnUrl) { if (GetCart().Count == 0) { return(RedirectToAction(nameof(Index), "Home")); } else { ViewBag.ReturnUrl = returnUrl; ViewBag.TotalValue = ModifyCart.GetTotalValue(GetCart()); ViewBag.Cart = GetCart(); ViewBag.PayMethods = new SelectList(await _context.PayMethods.ToListAsync(), "Id", "TitlePayMethod"); ViewBag.DeliveryMethods = new SelectList(await _context.DeliveryMethods.ToListAsync(), "Id", "TitleDeliveryMethod"); string role = User.FindFirst(x => x.Type == ClaimsIdentity.DefaultRoleClaimType)?.Value; if (!String.IsNullOrEmpty(role)) { if (role.Equals("client")) { int clientId = Convert.ToInt32(User.FindFirst(x => x.Type == ClaimsIdentity.DefaultNameClaimType).Value); Client client = await _context.Clients.FindAsync(clientId); if (client != null) { return(View(client)); } } } return(View()); } }
public void ShoppingCartTest() { // Home Page: access methods directly (static) HomePage.SearchItem(driver, "iPhone"); HomePage.ClickSearch(driver); // Add to Cart Page Object AddtoCart oAdd = new AddtoCart(); oAdd.Add(driver, "btnApple_Iphone_6.jpg"); // Modify Cart var ModifyCart = new ModifyCart(driver); ModifyCart.UpdateCart("6"); // Checkout: Checkout Object using Page Factory var oCheckoutPage = new Checkout(driver); oCheckoutPage.CustomerBilling("Timothy Short", "123 Main Street"); oCheckoutPage.CustomerShipping(); oCheckoutPage.ClickSubmit(); string Confirmation = driver.FindElement(By.CssSelector("body > font")).Text; Capture.Screenshot(driver, "Output", "ShoppingCartTest"); }
public async Task <IActionResult> RemoveFromCart(int productId, string returnUrl) { Product product = await _context.Products.FindAsync(productId); if (product != null) { cart = GetCart(); cart = ModifyCart.RemoveItem(cart, product); SetCard(cart); } return(RedirectToAction("Index", new { returnUrl })); }
public async Task <IActionResult> AddToCart(int productId, int quanity, string returnUrl) { Product product = await _context.Products.FindAsync(productId); if (product != null) { cart = GetCart(); if (quanity > 0) { cart = ModifyCart.RemoveItem(cart, product); cart = ModifyCart.Additem(cart, product, quanity); } else { cart = ModifyCart.Additem(cart, product, 1); } SetCard(cart); } return(RedirectToAction("Index", new { returnUrl })); }