Filter By Multiple Categories
I'm developing a search control with a few checkbox lists of taxons. I'd like to be able to put the results of the checkbox lists into a list of Guids and then find module builder items that have matching taxons. I cannot figure out how to filter a taxon list within a module builder item with the list of taxon guids I have. Any help?
public void Submit(object sender, EventArgs e) List<Guid> CategoriesChecked = new List<Guid>(); foreach (ListItem tag in MentorshipCategoriesList.Items) if (tag.Selected) CategoriesChecked.Add(new Guid(tag.Value)); List<Guid> IndustriesChecked = new List<Guid>(); foreach (ListItem tag in MentorshipIndustriesList.Items) if (tag.Selected) IndustriesChecked.Add(new Guid(tag.Value)); List<Guid> BusinessStagesChecked = new List<Guid>(); foreach (ListItem tag in MentorshipBusinessStagesList.Items) if (tag.Selected) BusinessStagesChecked.Add(new Guid(tag.Value)); bool PreviousExperience = MentorshipExperience.Checked; FindMentors(CategoriesChecked, IndustriesChecked, BusinessStagesChecked, PreviousExperience); protected void FindMentors(List<Guid> CategoriesChecked, List<Guid> IndustriesChecked, List<Guid> BusinessStagesChecked, bool PreviousExperience) DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(); Type mentorType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Mentors.Mentor"); var mentors = (dynamicModuleManager.GetDataItems(mentorType)) .Where(i => i.GetValue<IList<Guid>>("mentorshipcategories").IM_LOST_HERE && i.Visible == true); If anyone else runs into this, we ended up using:
var mentors = (dynamicModuleManager.GetDataItems(mentorType)).Where(i => i.Visible == true && i.Status == ContentLifecycleStatus.Live && (i.GetValue<IList<Guid>>("mentorshipcategories").Any(j => CategoriesChecked.Contains(j)) || i.GetValue<IList<Guid>>("industries").Any(j => CategoriesChecked.Contains(j)) || i.GetValue<IList<Guid>>("businessstages").Any(j => CategoriesChecked.Contains(j))));