// Edit privilege async Task EditPrivilege() { try { var user = SelectedUser; if (user == null) { return; } var grant = SelectedPrivilegeGrant; if (grant == null) { return; } // Bind to data editPrivilegeDialog.BindToGrant(user.Name, grant); if (editPrivilegeDialog.ShowDialog() == DialogResult.OK) { // Get the selected database and privilege to grant var username = editPrivilegeDialog.Username; var database = editPrivilegeDialog.Database; var privilege = editPrivilegeDialog.SelectedPrivilege; // Ensure a database was selected if (string.IsNullOrWhiteSpace(database)) { AppForm.DisplayError("You must supply a database to update a privilege for."); return; } InfluxDbApiResponse response = null; // If "None" was selected then we actually need to revoke the existing privilege if (privilege == InfluxDbPrivileges.None) { response = await InfluxDbClient.RevokePrivilegeAsync(username, grant.Privilege, database); } // Otherwise just grant the new privilege else { response = await InfluxDbClient.GrantPrivilegeAsync(username, privilege, database); } // Refresh the window if (response.Success) { await ExecuteRequestAsync(); } else { AppForm.DisplayError(response.Body); } // Update interface buttons UpdateUIState(); } } catch (Exception ex) { AppForm.DisplayException(ex); } }