private void AddProductExecute(object obj) { Product ourProduct = dataManager.GetProductByName(selectedProduct.Name); WindowFactory.CreateWeightEnterWindow(ourProduct); Food productInBase = schedule.Food.FirstOrDefault(p => p.Name == ourProduct.Name); if (productInBase != null) { CalculatorNutrients.CombineFood(productInBase, ourProduct); food[food.IndexOf(food.FirstOrDefault(p => p.Name == ourProduct.Name))] = new FoodViewModel(productInBase); } else { Food addingFood = new Food(); addingFood.Carbohydrates = ourProduct.Carbohydrates; addingFood.Fats = ourProduct.Fats; addingFood.KiloCalories = ourProduct.KiloCalories; addingFood.Protein = ourProduct.Protein; addingFood.Weight = ourProduct.Weight; addingFood.Name = ourProduct.Name; scheduleModel.Food.Add(addingFood); food.Add(new FoodViewModel(ourProduct)); } RaisePropertyChanged("CanReadyExecute"); }
private void AddDishExecute(object obj) { Dish dish = dataManager.GetDishByName(selectedDish.Name); Food ourDish = new Food(); ourDish.Carbohydrates = dish.Carbohydrates; ourDish.Fats = dish.Fats; ourDish.KiloCalories = dish.KiloCalories; ourDish.Protein = dish.Protein; ourDish.Weight = dish.Weight; ourDish.Name = dish.Name; WindowFactory.CreateWeightEnterWindow(ourDish); Food dishInBase = schedule.Food.FirstOrDefault(p => p.Name == ourDish.Name); if (dishInBase != null) { CalculatorNutrients.CombineFood(dishInBase, ourDish); food[food.IndexOf(food.FirstOrDefault(p => p.Name == ourDish.Name))] = new FoodViewModel(dishInBase); } else { scheduleModel.Food.Add(ourDish); food.Add(new FoodViewModel(ourDish)); } RaisePropertyChanged("CanReadyExecute"); }
private void AddExecute(object obj) { Product ourProduct = dataManager.GetProductByName(selectedProduct.Name); WindowFactory.CreateWeightEnterWindow(ourProduct); Product productInBase = dishModel.List.FirstOrDefault(p => p.Name == ourProduct.Name); if (productInBase != null) { CalculatorNutrients.CombineFood(productInBase, ourProduct); DishProducts[DishProducts.IndexOf(DishProducts.FirstOrDefault(p => p.Name == ourProduct.Name))] = new FoodViewModel(productInBase); } else { dishModel.List.Add(ourProduct); dishProducts.Add(new FoodViewModel(ourProduct)); } RaisePropertyChanged("Dish"); }