Ejemplo n.º 1
0
        private async void btn_AddIngredient_Click(object sender, EventArgs e)
        {
            int price = 0;

            if (string.IsNullOrWhiteSpace(txbxAddIngName.Text) ||
                !int.TryParse(txbxAddIngPrice.Text, out price))
            {
                MessageBox.Show("Invalid input");
                return;
            }

            var newIngredient = new Ingredient()
            {
                IngredientName = txbxAddIngName.Text,
                Price          = price
            };

            try
            {
                await _repo.AddNewIngredientAsync(newIngredient);

                MessageBox.Show("Successfully added new ingredient!");
            }
            catch
            {
                MessageBox.Show("Failed importing Ingredient. Please try again.");
            }

            GetAllIngredientsBtn_Click(sender, e);
        }