//Checkout Button Click private void chechoutButton_Click(object sender, RoutedEventArgs e) { ArrayList orderedBooks = new ArrayList(); //Added by Johan for Wishlist clearance int orderId; if (globalUserID > 0) { orderId = bookOrder.PlaceOrder(userData.UserID, bookOrder.GetOrderTotal()); MessageBox.Show("Your order has been placed. Your order id is " + orderId.ToString() + " and Total is " + bookOrder.GetOrderTotal()); //Code added by Johan to deleate books from wishlist if they exists orderedBooks = bookOrder.getOrderISBNList(); foreach (var bookISBN in orderedBooks) { bookWishList.RemoveItem(bookISBN.ToString(), userData.UserID); bookOrder.RemoveItem(bookISBN.ToString()); //Remove the books from the order } orderListView.ItemsSource = bookOrder.OrderItemList; //Wishlist development completed //Recommendations recommend = new Recommendations(userData.UserID); //recommend.ShowDialog(); } else { this.statusTextBlock.Text = "Log In Before Placing an Order"; } }
public void TestPriceTotal() { BookOrder newOrder; try { newOrder = new BookOrder(); double newTotal = newOrder.GetOrderTotal(); Assert.AreEqual(0, newTotal); } catch { Assert.Fail("Exception should be thrown"); } }
private void checkoutButton_Click(object sender, RoutedEventArgs e) { BookOrder bookOrder = new BookOrder(); bookOrder.updateOrderList(getBooksInfo()); if (userID == 0 || userID <= -1) { MessageBox.Show("You must be logged in to check out!"); } else if (getBooksInfo().Count == 0) { MessageBox.Show("Please add books to cart before checking out."); } else { int orderId1 = bookOrder.PlaceOrderFinal(userID); if (orderId1 == 0) { MessageBox.Show("Error placing order"); } else { MessageBox.Show(" Your order has been placed! \n\n Order Number: " + orderId1.ToString() + "\n\n Order Total with Tax(13%): $" + (bookOrder.GetOrderTotal()).ToString() + "\n\n Thank you for shopping at Novel Cloud!"); orderBooksList.ToList().ForEach(x => { orderBooksList.Remove(x); this.setOrderBooks(orderBooksList); }); } } }