private void ShowEditUserDialog(object obj) { if (obj != null) { var dialog = new EditUserDialog(obj as UserViewModel); dialog.ShowDialog(); } }
// Edit the selected user async Task EditUser() { try { var user = SelectedUser; if (user == null) { return; } editUserDialog.BindToUser(user); if (editUserDialog.ShowDialog() == DialogResult.OK) { // If there was no change in user status, there's nothing to do var updatedUser = editUserDialog.CreateUserFromDialog(); if (user.IsAdmin == updatedUser.IsAdmin) { return; } InfluxDbApiResponse response = null; // Otherwise carry out the appropriate API call based on adding or removing admin privileges if (updatedUser.IsAdmin) { response = await InfluxDbClient.GrantAdministratorAsync(updatedUser.Name); } else { response = await InfluxDbClient.RevokeAdministratorAsync(updatedUser.Name); } // Refresh the window if (response.Success) { await ExecuteRequestAsync(); } else { AppForm.DisplayError(response.Body); } // Update interface buttons UpdateUIState(); } } catch (Exception ex) { AppForm.DisplayException(ex); } }
private void EditUserCommandExecuted(object obj) { var dialog = new EditUserDialog(PHmi.Users, SelectedUser); if (EditUserDialogStyle != null) { dialog.Style = EditUserDialogStyle; } var result = dialog.ShowDialog(this); if (result == true && Paginator.RefreshCommand.CanExecute(null)) { Paginator.RefreshCommand.Execute(null); } }