public async Task RemoveFromRoleAsync(User user, string roleName, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); await new Task( () => { using (Role role = Role.FindByNormalizedName(roleName, connection, null)) using (UserRole userRole = UserRole.FindByUserIdAndRoleId(user.Id, role.Id, connection, null)) { if (role == null) { throw new UserException($"Não foi encontrado nenhum nível de acesso com o nome '{roleName}'!"); } if (userRole == null) { throw new UserException($"Não foi encontrado nenhum nível de acesso com o nome '{roleName}' para o usuário '{user.Nome}'!"); } userRole.Delete(connection, null); } } ); }
protected void EgvUserRole_RowCommand(object sender, CommandEventArgs e) { bool flag = false; int roleId = DataConverter.CLng(e.CommandArgument); string commandName = e.CommandName; if (commandName != null) { if (!(commandName == "ModifyRole")) { if (commandName == "DeleteRole") { flag = UserRole.Delete(roleId); } else if (commandName == "CommonPermissions") { BasePage.ResponseRedirect("RolePermissions.aspx?Action=Modify&RoleId=" + roleId); } else if (commandName == "FieldPermissions") { BasePage.ResponseRedirect("RoleFieldPermissions.aspx?PermissionsType=Role&RoleId=" + roleId); } } else { BasePage.ResponseRedirect("Role.aspx?Action=Modify&RoleId=" + roleId); } } if (flag) { AdminPage.WriteSuccessMsg("删除角色成功!", "RoleManage.aspx"); } }
/// <summary> /// Modify UserRole object to database /// <param name="o">UserRole to be modified.</param> /// <retvalue>void</retvalue> /// </summary> public void Delete(UserRole o) { if (o != null) { o.Delete(_conn); if (o.HasError) { _hasError = true; } } }
public int UBindUserRole(IEnumerable <UserRole> userRole) { return(_userRole.Delete(userRole)); }
public static void DeleteTodoResourceRole(int TodoId, int UserId) { UserRole.Delete(CreateTodoContainerKey(TodoId), TodoResourceRoleName, UserId); }
public static void DeleteEventResourceRole(int EventId, int UserId) { UserRole.Delete(CreateEventContainerKey(EventId), EventResourceRoleName, UserId); }
public static void DeleteDocumentTodoResourceRole(int DocumentId, int UserId) { UserRole.Delete(CreateDocumentContainerKey(DocumentId), DocumentTodoResource, UserId); }
public static void DeleteAdminRole(int UserId) { UserRole.Delete(AdminRoleName, UserId); }
public static void DeleteTaskTodoResourceRole(int TaskId, int UserId) { UserRole.Delete(CreateTaskContainerKey(TaskId), TaskTodoResource, UserId); }
public static void DeleteTaskManagerRole(int TaskId, int UserId) { UserRole.Delete(CreateTaskContainerKey(TaskId), TaskManagerRoleName, UserId); }
public static void DeleteIssueTodoResourceRole(int IssueId, int UserId) { UserRole.Delete(CreateIssueContainerKey(IssueId), IssueTodoResource, UserId); }
public static void DeleteIssueManagerRole(int IssueId, int UserId) { UserRole.Delete(CreateIssueContainerKey(IssueId), IssueManagerRoleName, UserId); }
public static void DeleteProjectStakeHolderRole(int ProjectId, int UserId) { UserRole.Delete(CreateProjectContainerKey(ProjectId), ProjectStakeHolderRoleName, UserId); }
public static void DeleteExecutiveManagerRole(int ProjectId, int UserId) { UserRole.Delete(CreateProjectContainerKey(ProjectId), ExecutiveManagerRoleName, UserId); }
public static void DeleteDocumentManagerRole(int DocumentId, int UserId) { UserRole.Delete(CreateDocumentContainerKey(DocumentId), DocumentManagerRoleName, UserId); }
public void DeleteTest() { UserRole temp = new UserRole("admin", "Administration"); Assert.True(temp.Delete()); }
public static void DeletePowerProjectManagerRole(int UserId) { UserRole.Delete(PowerProjectManagerRoleName, UserId); }