public RegisterAndUpdateOutput Create(IngredientInput ingredientInput) { var ingredient = new Ingredient(ingredientInput.Name, ingredientInput.Price); _ingredientRepository.Save(ingredient); return(new RegisterAndUpdateOutput { Success = true, Message = "Ingredient registered with success.", Data = ingredient }); }
public RecipeEditor(int bookId, IRecipe recipe) { InitializeComponent(); _bookId = bookId; _recipe = recipe; IngredientContainer.Children.Clear(); LoadContent(); this.KeyDown += (sender, keyEvent) => { if (keyEvent.Key == Key.Enter && !RecipeName.IsFocused) { IngredientInput input = new IngredientInput(); IngredientContainer.Children.Add(input); input.Select(); } }; }
public RegisterAndUpdateOutput Update(IngredientInput ingredientInput) { var ingredient = _ingredientRepository.GetById(ingredientInput.Id); if (ingredient == null) { return(null); } ingredient.Update(ingredientInput.Name, ingredientInput.Price); _ingredientRepository.Update(ingredient); return(new RegisterAndUpdateOutput { Success = true, Message = "Ingredient updated with success.", Data = ingredient }); }
public CreateRecipe(int bookID, RoutedEventHandler listener) { InitializeComponent(); _bookId = bookID; IngredientContainer.Children.Clear(); ingredientAdd.Click += IngredientAdd; IngredientContainer.Children.Add(new IngredientInput()); createBtn.Click += createRecipe; createBtn.Click += listener; this.KeyDown += (sender, keyEvent) => { if (keyEvent.Key == Key.Enter && !RecipeName.IsFocused) { IngredientInput input = new IngredientInput(); IngredientContainer.Children.Add(input); input.Select(); } }; }