public static List<Metadata> GetAllMetadataDatasetsWithListOfSearchCriteria(List<Metadata> data, SearchCriteria searchCriteria)
{
IEnumerable<Metadata> newData = new List<Metadata>();
List<Metadata> temp = new List<Metadata>();
if (searchCriteria.SearchCriteriaList.Count() > 0)
{
bool first = true;
foreach (SearchCriterion sco in searchCriteria.SearchCriteriaList)
{
IEnumerable<Metadata> tempValue = new List<Metadata>();
temp = new List<Metadata>();
if (sco.Values.Count > 0)
{
IEnumerable<Metadata> newValueData = new List<Metadata>();
foreach (string value in sco.Values)
{
//newValueData = new List<Metadata>();
if (sco.SearchComponent.Name == "all") temp = GetAllMetadataDatasetsByValue(data, value);
else
{
if (sco.SearchComponent.Type == SearchComponentBaseType.Property)
{
Property sc = (Property)sco.SearchComponent;
if (sc.UIComponent == Property.UI_RANGE && sc.DataType == DataHelperConstClass.PROPERTY_DATATYPE_DATE)
{
bool desc = false;
if (sc.DataSourceKey == "endDate")
desc = true;
temp = GetAllMetadataDatasetsByRangeNode(data, sco.SearchComponent.Name, value, desc);
}
else
{
temp = GetAllMetadataDatasetsByNode(data, sco.SearchComponent.Name, value);
}
}
else
{
temp = GetAllMetadataDatasetsByNode(data, sco.SearchComponent.Name, value);
}
}
if (tempValue.Count() == 0) tempValue = temp;
else
{
tempValue = tempValue.Union(temp);
}
}
if (first == false)
{
newData = newData.Intersect(tempValue);
}
else
{
newData = tempValue;
first = false;
}
}
else
{
if (first == true)
{
newData = data;
first = false;
}
else newData = newData.Intersect(data);
}
}
return newData.ToList();
}
else return data;
}