Add series info for parent will null order.

This commit is contained in:
Michael Bucari-Tovo 2022-05-26 16:43:56 -06:00
parent 845af854bd
commit 1b2ec67726
3 changed files with 5 additions and 3 deletions

View File

@ -137,6 +137,7 @@ namespace AudibleUtilities
//Add the parent to the library because it contains the series //Add the parent to the library because it contains the series
//description, series rating, and series cover art which differ //description, series rating, and series cover art which differ
//from the individual episodes' values. //from the individual episodes' values.
item.Series = new Series[]{ new Series { Asin = item.Asin, Title = item.TitleWithSubtitle } };
items.Add(item); items.Add(item);
} }
else if (!item.IsEpisodes) else if (!item.IsEpisodes)

View File

@ -109,6 +109,7 @@ namespace LibationWinForms.GridView
=> gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series)); => gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series));
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries) public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> gridEntries)
=> gridEntries.Series().Where(i => i.Children.Count == 0); => 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(); public static bool IsEpisodeChild(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any() && lb.Book.SeriesLink.First().Order is not null;
public static bool IsEpisodeParent(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any() && lb.Book.SeriesLink.First().Order is null;
} }
} }

View File

@ -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 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.IsEpisodeWithSeries()).ToList(); var episodes = dbBooks.Where(b => b.IsEpisodeChild()).ToList();
foreach (var series in episodes.Select(lb => lb.Book.SeriesLink.First()).DistinctBy(s => s.Series)) 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 // add new to top
if (existingItem is null) if (existingItem is null)
{ {
if (libraryBook.IsEpisodeWithSeries()) if (libraryBook.IsEpisodeChild())
{ {
LibraryBookEntry lbe; LibraryBookEntry lbe;
//Find the series that libraryBook belongs to, if it exists //Find the series that libraryBook belongs to, if it exists