Move filter query and RowComparer into UI base

This commit is contained in:
Mbucari 2023-04-10 13:05:38 -06:00
parent e52772826a
commit 666b5d83df
4 changed files with 106 additions and 95 deletions

View file

@ -1,4 +1,5 @@
using DataLayer;
using ApplicationServices;
using DataLayer;
using System;
using System.Collections.Generic;
using System.Linq;
@ -39,6 +40,20 @@ namespace LibationUiBase.GridView
return null;
}
}
public static HashSet<IGridEntry>? FilterEntries(this IEnumerable<IGridEntry> entries, string searchString)
{
if (string.IsNullOrEmpty(searchString)) return null;
var searchResultSet = SearchEngineCommands.Search(searchString);
var booksFilteredIn = entries.BookEntries().Join(searchResultSet.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => (IGridEntry)lbe);
//Find all series containing children that match the search criteria
var seriesFilteredIn = entries.SeriesEntries().Where(s => s.Children.Join(searchResultSet.Docs, lbe => lbe.AudibleProductId, d => d.ProductId, (lbe, d) => lbe).Any());
return booksFilteredIn.Concat(seriesFilteredIn).ToHashSet();
}
}
#nullable disable
}