private static void SetEntityPermission(IDictionary<Guid, FolderPermission> entityPermissions, Guid entityGuid, FolderPermission permission) { if (entityPermissions.ContainsKey(entityGuid)) entityPermissions[entityGuid] = entityPermissions[entityGuid].Or(permission); else entityPermissions.Add(entityGuid, permission); }
private bool UserHasPemissionToFolder(Guid userGuid, FolderPermission permission) { return UserPermissions.ContainsKey(userGuid) && (UserPermissions[userGuid] & permission) == permission; }
private bool GroupsHavePermissionToFolder(IEnumerable<Guid> groupGuids, FolderPermission permission) { return groupGuids.Any(groupGuid => GroupPermissions.ContainsKey(groupGuid) && (GroupPermissions[groupGuid] & permission) == permission); }
/// <summary> /// Return true if user or group has permission to folder /// </summary> /// <param name="userGuid"></param> /// <param name="groupGuids"></param> /// <param name="permission"></param> /// <returns></returns> public bool DoesUserOrGroupHavePermission(Guid userGuid, IEnumerable<Guid> groupGuids, FolderPermission permission) { return UserHasPemissionToFolder(userGuid, permission) || GroupsHavePermissionToFolder(groupGuids, permission); }