I am not really sure why this is not working correctly. Is it possibly because I am trying to use the expressions on a data class instead of a single field in that class?
adminOnlyGroups
is supposed to return the groups that the admin has and the user doesn't but it is returning all of the admin groups
userOnlyGroups
is doing the same, it is returning all of the user groups
commonGroups
is supposed to return the groups that they have in common which there are two of, but it is returning null or empty
Data Class
[DataContract]
public class InvestigatorGroupData
{
[DataMember]
public int InvestigatorGroupId { get; set; }
[DataMember]
public string InvestigatorGroupName { get; set; }
}
Snippet of my controller
IEnumerable<InvestigatorGroupData> adminGroups = proxy.GetInvestigatorGroups(adminId);
IEnumerable<InvestigatorGroupData> userGroups = proxy.GetInvestigatorGroups(userId);
// Groups that admin has and user doesn't. These will be enabled and unselected
IEnumerable<InvestigatorGroupData> adminOnlyGroups = adminGroups.Except(userGroups);
// Groups that the user has and admin doesn't. These will be disabled and selected
IEnumerable<InvestigatorGroupData> userOnlyGroups = userGroups.Except(adminGroups);
// Groups in common. These will be enabled and selected
IEnumerable<InvestigatorGroupData> commonGroups = adminGroups.Intersect(userGroups);
if (commonGroups.IsNullOrEmpty())
{
return View("Error");
}