Fix bug and add groundwork for future feature
This commit is contained in:
parent
0a6e55dcb7
commit
c95ba0764b
3 changed files with 10 additions and 4 deletions
|
|
@ -109,5 +109,6 @@ namespace LibationWinForms.GridView
|
|||
=> gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series));
|
||||
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries)
|
||||
=> gridEntries.Series().Where(i => i.Children.Count == 0);
|
||||
public static bool IsEpisodeWithSeries(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace LibationWinForms.GridView
|
|||
{
|
||||
var geList = dbBooks.Where(b => b.Book.ContentType is not ContentType.Episode).Select(b => new LibraryBookEntry(b)).Cast<GridEntry>().ToList();
|
||||
|
||||
var episodes = dbBooks.Where(b => b.Book.ContentType is ContentType.Episode).ToList();
|
||||
var episodes = dbBooks.Where(b => b.IsEpisodeWithSeries()).ToList();
|
||||
|
||||
foreach (var series in episodes.Select(lb => lb.Book.SeriesLink.First()).DistinctBy(s => s.Series))
|
||||
{
|
||||
|
|
@ -117,7 +117,7 @@ namespace LibationWinForms.GridView
|
|||
// add new to top
|
||||
if (existingItem is null)
|
||||
{
|
||||
if (libraryBook.Book.ContentType is ContentType.Episode)
|
||||
if (libraryBook.IsEpisodeWithSeries())
|
||||
{
|
||||
LibraryBookEntry lbe;
|
||||
//Find the series that libraryBook belongs to, if it exists
|
||||
|
|
@ -148,7 +148,7 @@ namespace LibationWinForms.GridView
|
|||
|
||||
series.NotifyPropertyChanged();
|
||||
}
|
||||
else
|
||||
else if (libraryBook.Book.ContentType is not ContentType.Episode)
|
||||
//Add the new product
|
||||
bindingList.Insert(0, new LibraryBookEntry(libraryBook));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue