Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
        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";
        }