Beispiel #1
0
        public void CombineIngredients()
        {
            foreach (Recipe recipe1 in Recipes)
            {
                foreach (List <RecipeIngredient> recipeIngredientsList1 in recipe1.RecipeIngredients)
                {
                    foreach (RecipeIngredient recipeIngredient1 in recipeIngredientsList1)
                    {
                        //if (recipeIngredient1.Selected)
                        {
                            recipeIngredient1.RecipeRequired = recipeIngredient1.GetRecipeRequired();



                            //search RecipeIngredients for item
                            bool found = false;
                            foreach (RecipeIngredient recipeIngredient in RecipeIngredients)
                            {
                                if (recipeIngredient.Ingredient.ExternalID == recipeIngredient1.Ingredient.ExternalID || recipeIngredient.Ingredient.Description == recipeIngredient1.Ingredient.Description)
                                {
                                    found = true;

                                    recipeIngredient.RecipeRequired += recipeIngredient1.RecipeRequired;
                                }
                            }
                            if (!found)
                            {
                                RecipeIngredients.Add(recipeIngredient1);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
 async Task AddIngredient()
 {
     try
     {
         RecipeIngredients.Add(IngredientInsert);
         IngredientInsert = "";
         OnPropertyChanged(nameof(CanRecipeSubmit));
     }
     catch (Exception ex)
     {
         //_logger.Error("Got exception", ex);
         await Application.Current.MainPage.DisplayAlert("Błąd", ex.Message, "Ok");
     }
 }
 public void AddIngredientTextBox()
 {
     try
     {
         RecipeIngredients.Add(IngredientInsert);
         IngredientInsert = "";
         NotifyOfPropertyChange(() => CanAddRecipeSubmit);
     }
     catch (Exception ex)
     {
         _logger.Error("Got exception", ex);
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }
 private void AddIngredientExecute(object obj)
 {
     if (obj is Ingredient ingredient)
     {
         RecipeIngredients.Add(new Ingredient {
             Name = ingredient.Name, Amount = ingredient.Amount, Typ = ingredient.Typ
         });
     }
     else
     {
         RecipeIngredients.Add(new Ingredient {
             Name = "", Amount = 0, Typ = IngredientTyp.Kilogram
         });
     }
 }
        public AddRecipeViewModel()
        {
            #region Init Commands
            #region Init Phase - Commands
            AddPhaseCommand          = new RelayCommand(AddPhaseExecute);
            DuplicatePhaseCommand    = new RelayCommand(DuplicatePhaseExecute);
            DeletePhaseCommand       = new RelayCommand(DeletePhaseExecute);
            PositionUpPhaseCommand   = new RelayCommand(PositionUpPhaseExecute, PositionUpPhaseCanExecute);
            PositionDownPhaseCommand = new RelayCommand(PositionDownPhaseExecute, PositionDownPhaseCanExecute);
            AddPumpIntervalCommand   = new RelayCommand(AddPumpIntervalExecute);
            #endregion

            #region Init Ingredient - Commands
            AddIngredientCommand       = new RelayCommand(AddIngredientExecute);
            DuplicateIngredientCommand = new RelayCommand(DuplicateIngredientExecute);
            DeleteIngredientCommand    = new RelayCommand(DeleteIngredientExecute);
            #endregion

            SaveRecipeCommand = new RelayCommand(SaveRecipeExecute, SaveRecipeCanExecute);
            #endregion

            using var db  = new BreweryContext();
            PumpIntervals = new ObservableCollection <PumpInterval>(db.PumpIntervals.ToList());

            foreach (var ingredient in db.FoundationIngrediets.ToList())
            {
                RecipeIngredients.Add(new Ingredient {
                    Name = ingredient.Name, Amount = ingredient.Amount, Typ = ingredient.Typ
                });
            }

            RecipePhases.Add(new Phase {
                Position = 0, Name = "Aufwärmen", PeriodOfMinutes = 60, TargetTemperature = 50, Typ = PhaseTyp.HeatUp, PumpInterval = PumpIntervals[0]
            });
            RecipePhases.Add(new Phase {
                Position = 1, Name = "Halten", PeriodOfMinutes = 60, TargetTemperature = 50, Typ = PhaseTyp.KeepHeat, PumpInterval = PumpIntervals[2]
            });
            RecipePhases.Add(new Phase {
                Position = 2, Name = "Aufwärmen 2", PeriodOfMinutes = 60, TargetTemperature = 70, Typ = PhaseTyp.HeatUp, PumpInterval = PumpIntervals[2]
            });
            RecipePhases.Add(new Phase {
                Position = 3, Name = "Rast 2", PeriodOfMinutes = 60, TargetTemperature = 70, Typ = PhaseTyp.KeepHeat, PumpInterval = PumpIntervals[2]
            });
        }
Beispiel #6
0
 public void AddRecipeIngredient(RecipeIngredient recipeIngredient)
 {
     RecipeIngredients.Add(recipeIngredient);
 }