public async ValueTask <OperationResult> ValidateIdsAsync( IReadOnlyCollection <long> roleIds, CancellationToken cancellationToken) { RolesLogMessages.RoleIdsValidating(_logger, roleIds); if (!roleIds.Any()) { RolesLogMessages.RoleIdsValidationSucceeded(_logger); return(OperationResult.Success); } var invalidRoleIds = roleIds .Except((await GetCurrentIdentitiesAsync(cancellationToken)) .Select(x => x.Id)) .ToArray(); if (invalidRoleIds.Length == 0) { RolesLogMessages.RoleIdsValidationSucceeded(_logger); return(OperationResult.Success); } else if (invalidRoleIds.Length == 1) { RolesLogMessages.RoleIdsValidationFailed(_logger, invalidRoleIds); return(new DataNotFoundError($"Role ID {invalidRoleIds.First()}")); } else { RolesLogMessages.RoleIdsValidationFailed(_logger, invalidRoleIds); return(new DataNotFoundError($"Role IDs {string.Join(", ", invalidRoleIds)}")); } }