public async Task <PartialViewResult> RemoveItem(RemovableItem RI) { ShoppingCart shoppingCart = new ShoppingCart(_context); List <CartItems> updatdedCart = await shoppingCart.RemoveFromCart(RI); return(PartialView("~/Views/Carts/_CartPartial.cshtml", updatdedCart)); }
public async Task <List <CartItems> > RemoveFromCart(RemovableItem RI) { CartItems item = new CartItems(); item.ID = RI.cartitemid; _context.CartItems.Attach(item); _context.CartItems.Remove(item); await _context.SaveChangesAsync(); ShoppingCartItems = GetCart(RI.cartid); return(ShoppingCartItems); }
public async Task <IActionResult> RemoveItemAtCheckout(string cartid, int cartitemid) { RemovableItem RI = new RemovableItem(); RI.cartid = cartid; RI.cartitemid = cartitemid; ShoppingCart shoppingCart = new ShoppingCart(_context); List <CartItems> updatdedCart = await shoppingCart.RemoveFromCart(RI); CartViewModel CVM = new CartViewModel(); CVM.CartID = RI.cartid; CVM.CurrentCart = shoppingCart.GetCart(CVM.CartID); if (CVM.CurrentCart != null) { CVM.NumberOfItems = CVM.CurrentCart.Count; CVM.CartTotal = shoppingCart.Total(CVM.CurrentCart); return(View("~/Views/Carts/Checkout.cshtml", CVM)); } else { return(RedirectToAction("Index", "Home")); } }