private void SaveExecute() { if (String.IsNullOrEmpty(Recipe.RecipeName) || String.IsNullOrEmpty(Recipe.Type) || String.IsNullOrEmpty(Recipe.NumberOfPersons.ToString()) || Recipe.NumberOfPersons == 0 || String.IsNullOrEmpty(Recipe.Description)) { MessageBox.Show("Please fill all fields.", "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) { //changing id and author of recipe is user is administrator Recipe.Author = User.NameAndSurname; Recipe.UserId = User.UserId; Recipe.NameAndSurname = User.NameAndSurname; bool isEdited = recipes.EditRecipe(Recipe); if (isEdited == true) { string message = String.Format("Recipe {0} of user {1} is edited.", recipe.RecipeName, OldAuthor); MessageBox.Show(message, "Notification", MessageBoxButton.OK); if (Recipe.NameAndSurname == "Administrator") { AdminView adminView = new AdminView(); editRecipe.Close(); adminView.ShowDialog(); } else { UserView userView = new UserView(users.FindUser(recipe.UserId)); editRecipe.Close(); userView.ShowDialog(); } } else { MessageBox.Show("Recipe cannot be edited.", "Notification", MessageBoxButton.OK); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }