Sorry but this will be a little long..
I want to show members from picked groups, so If I have following members:
member 1 with groups: group 1, group 2, group 3
member 2 with groups: group 1, group 2
member 3 with groups: group 1
So if I only choose group 1 I will get all members, but If i choose group 1, group 2, group 3 I will only get member 1.
So first ill get all members In all the groups like this
List<List<IMember>> listWithMemberInGroupsList = new List<List<IMember>>();
var memberService = ApplicationContext.Current.Services.MemberService;
foreach (string group in memberGroups)
{
List<IMember> membersInGroup = memberService.GetMembersByGroup(group).ToList();
listWithMemberInGroupsList.Add(membersInGroup);
}
Then I got a list with list of members then I have to find the members which is in all the lists, This I made with the intersection metod on a list.
public List<IMember> getMembersToshow(List<List<IMember>> listWithMemberInGroupsList , int i = 0)
{
List<IMember> MembersToAddToPage = new List<IMember>();
while (i < listWithMemberInGroupsList.Count)
{
int compareListInt = i + 1;
if (i == 0)
{
MembersToAddToPage = groupWithMemberList[i].Intersect(listWithMemberInGroupsList [compareListInt]).ToList();
}
else
{
MembersToAddToPage = compareNextListWithLastResult(MembersToAddToPage, groupWithMemberList[compareListInt]);
}
i = i + 2;
}
return MembersToAddToPage;
}
public List<IMember> compareNextListWithLastResult(List<IMember> resultList, List<IMember> compareList)
{
List<IMember> MembersToAddToPage = new List<IMember>();
MembersToAddToPage = resultList.Intersect(compareList).ToList();
return MembersToAddToPage;
}
Now I cant find a way to make this faster because unfortunately it's a little slow by now.
Get only members in choosen membergroubs
Sorry but this will be a little long.. I want to show members from picked groups, so If I have following members:
member 1 with groups: group 1, group 2, group 3
member 2 with groups: group 1, group 2
member 3 with groups: group 1
So if I only choose group 1 I will get all members, but If i choose group 1, group 2, group 3 I will only get member 1.
So first ill get all members In all the groups like this
Then I got a list with list of members then I have to find the members which is in all the lists, This I made with the intersection metod on a list.
Now I cant find a way to make this faster because unfortunately it's a little slow by now.
is working on a reply...