I am trying to get the list of Roles that have a particular permission for a particular Node ID. This is what I have:
public static IEnumerable<int> GetRolesForPermissions(int nodeId, NodePermissionsEnum permission)
{
var aclProvider = new AclProvider(new TreeProvider());
var items = aclProvider.GetACLItems(nodeId);
if (!DataHelper.IsEmpty(items))
{
var acls = items.Tables[0].Rows;
foreach (DataRow acl in acls)
{
var aclId = (int)acl["AclID"];
var roles = aclProvider.GetAllowedRoles(aclId, permission, "RoleID");
if (!DataHelper.IsEmpty(roles))
{
var allowedRoles = roles.Tables[0].Rows;
foreach (DataRow allowedRole in allowedRoles)
{
yield return (int)allowedRole["RoleID"];
}
}
}
}
}
It works, but it doesn't seem as fast as it could be. Is there a better way?