private void AddNewIngredientButtonAddRecipe_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(AddNewIngredientTextBoxAddRecipe.Text)) { MessageBox.Show("An ingredient must have a name!"); } else { var newIngredientToAdd = new Ingredient { Name = AddNewIngredientTextBoxAddRecipe.Text }; _ingredientsToAdd.Add(newIngredientToAdd); _recipeRepository.AddIngredient(newIngredientToAdd); AddNewIngredientTextBoxAddRecipe.Clear(); ExistingIngredientsListBox.DataSource = _recipeRepository.GetAllIngredients(); } }
public AddRecipeForm(string selectedRestaurantName) { InitializeComponent(); _recipeRepository = new RecipeRepository(); _restaurantOfRecipeName = selectedRestaurantName; _ingredientsToAdd = new List <Ingredient>(); var ingredients = _recipeRepository.GetAllIngredients(); ExistingIngredientsListBox.DataSource = ingredients; ExistingIngredientsListBox.DisplayMember = "Name"; var existingRecipes = _recipeRepository.GetAllExistingRecipes(); ExistingRecipesListBox.DataSource = existingRecipes; ExistingRecipesListBox.DisplayMember = "Name"; }