/// <summary> /// Aktiviert oder deaktiviert einen Benutzer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToggleUserActivateStateButton_Click(object sender, RoutedEventArgs e) { try { UserAccount currentUserAccount = UserDataGrid.SelectedItem as UserAccount; if (currentUserAccount != null) { if (currentUserAccount.IsAdmin && currentUserAccount.IsActive && UserAccount.GetUserAccounts().Where(u => u.IsAdmin).ToList().Count <= 1) { throw new Exception(IniParser.GetSetting("ERRORMSG", "deactivateAdmin")); } if (UserSession.userAccountID.Equals(currentUserAccount.UserAccountID)) { throw new Exception(IniParser.GetSetting("ERRORMSG", "selfDeactivation")); } var state = currentUserAccount.IsActive; var message = string.Format(IniParser.GetSetting("USER", "confirmationFormatString"), currentUserAccount.Username, ((state) ? IniParser.GetSetting("FILTER", "inactive") : IniParser.GetSetting("FILTER", "active"))); var dialogResult = MessageBox.Show(message, IniParser.GetSetting("USER", "confirmationNeeded"), MessageBoxButton.OKCancel, MessageBoxImage.Question); if (dialogResult == MessageBoxResult.OK) { if (state) { UserAccount.Deactivate(currentUserAccount.UserAccountID); } else { UserAccount.Activate(currentUserAccount.UserAccountID); } this.userAccounts = UserAccount.GetUserAccounts(); if (this.userAccounts != null) { this.userAccounts.OrderByDescending(u => u.IsActive); } if (this.parentToolbar.searchPanel.searchBox.Text == IniParser.GetSetting("APPSETTINGS", "search")) { processKeyUp(""); } else { processKeyUp(this.parentToolbar.searchPanel.searchBox.Text); } } } } catch (Exception ex) { MessageBoxEnhanced.Error(ex.Message); } }