public void SaveRecipeExecute() { if (IngredientList == null || IngredientList.Count == 0) { MessageBox.Show("Please first add ingredients.", "Notification"); } else { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to save the recipe?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bool isConfirmed = recipes.ConfirmRecipe(Recipe); if (isConfirmed == true) { //if user select item from list and then changes foreach (var ingredient in IngredientList) { ingredients.EditIngredient(ingredient); } MessageBox.Show("Recipe is created.", "Notification", MessageBoxButton.OK); if (Recipe.Author == "Administrator") { AdminView adminView = new AdminView(); addIngredients.Close(); adminView.ShowDialog(); } else { UserView userView = new UserView(users.FindUser(recipe.UserId)); addIngredients.Close(); userView.ShowDialog(); } } else { MessageBox.Show("Recipe cannot be created.", "Notification", MessageBoxButton.OK); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }