private void button1_Click(object sender, EventArgs e) { if (!ConnectionManager.IsAuthenticated) { return; } //create order ProductContext context = new ProductContext(); var items = context.GetCartItems(ConnectionManager.ActiveCustomerId); if (items == null || !items.Any()) { MessageBox.Show("Please add items to cart before checkout.", "Checkout items", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } context.CreateOrder(ConnectionManager.ActiveCustomerId, context.GetCartItems(ConnectionManager.ActiveCustomerId)); //refresh this.LoadShoppingCartItems(); MessageBox.Show("Order placed successfully", "Order Placed", MessageBoxButtons.OK, MessageBoxIcon.Information); }