/// <summary> /// Revoke a Role from this Identity. /// </summary> /// <param name="roleId"></param> public void RevokeRole(Guid roleId) { var assignedRole = AssignedRoles.FirstOrDefault(x => x.RoleId == roleId); if (assignedRole == null) { return; } AssignedRolesCollection.Remove(assignedRole); }
/// <summary> /// Assign this Identity to a Role. /// </summary> /// <param name="role"></param> /// <returns></returns> public AssignedRole AssignRole(Role role) { var assignedRole = AssignedRoles.FirstOrDefault(x => x.RoleId == role.Id); if (assignedRole == null) { assignedRole = new AssignedRole(this, role); AssignedRolesCollection.Add(assignedRole); } return(assignedRole); }