public static IEnumerable <IPublishedContent> FilterSelection(IEnumerable <IPublishedContent> source, string author, string category, string month, string year) { var filterByCategory = !string.IsNullOrWhiteSpace(category); var filterByAuthor = !string.IsNullOrWhiteSpace(author); if (filterByAuthor && filterByCategory) { var postsInCategory = DataHelpers.FilterByPrevalueName(source, "category", category); var postsByAuthor = DataHelpers.FilterByPrevalueName(source, "author", author); source = postsInCategory.Intersect(postsByAuthor).ToList(); } else { if (filterByAuthor) { source = DataHelpers.FilterByPrevalueName(source, "author", author); } if (filterByCategory) { source = DataHelpers.FilterByPrevalueName(source, "category", category); } } if (!string.IsNullOrWhiteSpace(year)) { source = DataHelpers.FilterByYearAndMonth(source, month, year, "releaseDate"); } return(source); }
public static IEnumerable <IPublishedContent> FilterSelection(IEnumerable <IPublishedContent> source, string category, string month, string year) { if (!string.IsNullOrWhiteSpace(category)) { source = FilterByDocumentTypeUrlSegment(source, category); } if (!string.IsNullOrWhiteSpace(year)) { source = DataHelpers.FilterByYearAndMonth(source, month, year, "releaseDate"); } return(source); }
public static IEnumerable <IPublishedContent> AllFilteredNewsArticles(UmbracoHelper umbraco, string category, string month, string year) { var allNewsArticles = AllOrderedArticles(umbraco); if (!string.IsNullOrWhiteSpace(category)) { allNewsArticles = FilterByDocumentTypeUrlSegment(allNewsArticles, category); } if (!string.IsNullOrWhiteSpace(year)) { allNewsArticles = DataHelpers.FilterByYearAndMonth(allNewsArticles, year, month, "releaseDate"); } return(allNewsArticles); }