Beispiel #1
0
        // Add selected product to cart
        private async void AddProductBtn_Click(object sender, EventArgs e)
        {
            if ((gridViewProducts.SelectedRows.Count <= 0) ||
                !(gridViewProducts.SelectedRows[0].DataBoundItem is Product))
            {
                return;
            }

            // Save selected product from datagridview to product object
            var product = (Product)gridViewProducts.SelectedRows[0].DataBoundItem;

            // Fill product List<Ingredients> from database table ProductHaveIngredients
            product.Ingredients = (await _repo.GetHaveIngredientsAsync(product.ProductID)).ToList();

            AddProductToCart(product);
        }