private void BtnDeactivate_Click(object sender, RoutedEventArgs e) { if (btnDeactivate.Content.ToString() == "Deactivate") { try { var confirmPage = new frmConfirmAction(CrudFunction.Deactivate); bool?confirm = confirmPage.ShowDialog(); if (confirm == true) { try { _recipeManager.DeactivateRecipe(_oldRecipe.RecipeID); MessageBox.Show("Deactivation success"); _oldRecipe.Active = false; SetupEditPage(); } catch (Exception) { MessageBox.Show("Deactivation cancelled or failed."); } } else { MessageBox.Show("Deactivation cancelled or failed."); } } catch (Exception) { throw; } } else if (btnDeactivate.Content.ToString() == "Reactivate") { try { var confirmPage = new frmConfirmAction(CrudFunction.Reactivate); bool?confirm = confirmPage.ShowDialog(); if (confirm == true) { try { _recipeManager.ReactivateRecipe(_oldRecipe.RecipeID); MessageBox.Show("Reactivation success"); _oldRecipe.Active = true; SetupEditPage(); } catch (Exception) { MessageBox.Show("Reactivation cancelled or failed."); } } else { MessageBox.Show("Reactivation cancelled or failed."); } } catch (Exception) { throw; } } }