// 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); } }