private void SetUserGroups(Guid userId, IReadOnlyList<string> authenticatedGroups)
{
IEnumerable<Group> groups = GetGroupsWithExternalGroup(queryService.GetGroups());
foreach (var group in groups)
{
if (authenticatedGroups.Any(o => group.ExternalGroupName.Equals(o, StringComparison.OrdinalIgnoreCase)))
{
AddGroup(userId, group.Id);
}
else
{
RemoveGroup(userId, group.Id);
}
}
}