public async Task <IActionResult> Receipt() { string userEmail = User.Identity.Name; var user = await _userManager.FindByEmailAsync(userEmail); string userID = user.Id; Order ord = new Order(); ord.UserID = userID; Cart cartObj = await _cart.GetCart(userID); //get all the items in the cart IEnumerable <ShoppingCartItem> cartitems = await _shoppingCartItem.GetAllShoppingCartItems(cartObj.ID); decimal totalprice = 0m; //convert it to orderitem foreach (var item in cartitems) { OrderedItems tempOrdItem = new OrderedItems(); tempOrdItem.OrderID = ord.ID; totalprice += (item.ProdQty * item.Product.Price); await _shoppingCartItem.DeleteShoppingCartItem(item.ID); } ord.Totalprice = totalprice; return(View(ord)); }
public async Task <IActionResult> DeleteItem(int?id) { if (id == null) { return(NotFound()); } await _shoppingCartItem.DeleteShoppingCartItem((int)id); return(RedirectToAction(nameof(Index))); }