Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void LoadShoppingCartItems()
        {
            if (!ConnectionManager.IsAuthenticated)
            {
                return;
            }
            ProductContext context   = new ProductContext();
            var            cartItems = context.GetCartItems(ConnectionManager.ActiveCustomerId);

            this.dataGridView1.DataSource = cartItems.ConvertCollection()?.ToList();

            var totalAmount = cartItems.Sum(c => c.quantityOrdered * c.Beer.price);

            lblTotalCartAmount.Text = totalAmount.ToString();
        }