private List <Book> GetRelatedBooks(Book book) { List <Collection> collections = db.CollectionBooks.Include("Collection") .Where(cb => cb.BookId == book.Id) .Select(cb => cb.Collection) .ToList(); List <Book> books = new List <Book>(); foreach (Collection c in collections) { books = books.Concat(db.CollectionBooks.Include("Book") .Where(cb => cb.CollectionId == c.Id && cb.Book.Thumbnail != null) .Select(cb => cb.Book)) .ToList(); } books = books.GroupBy(b => b.GoogleVolumeId, (googleId, Books) => new { Key = googleId, Count = Books.Count(), Value = Books.FirstOrDefault() }).OrderByDescending(g => g.Count) .Select(g => g.Value) .Take(6) .ToList(); books.Remove(book); return(books); }
private void AddBooksToClubIndexViewModel(ClubIndexViewModel viewModel) { List <Book> books = GetBooksForClubIndexViewModel(viewModel.Members); viewModel.Books = books.GroupBy(b => b.GoogleVolumeId, (googleId, Books) => new { Count = Books.Count(), Key = googleId, Value = Books.FirstOrDefault() }).OrderByDescending(g => g.Count).Select(g => g.Value).ToList(); }
public override string ToString() { StringBuilder RetVal = new StringBuilder(); RetVal.AppendLine(TextBox.BuildDynamic($"Repository {Name}, location={RootPath}")); RetVal.AppendLine($"Found {Books.Count()} books"); RetVal.AppendLine($"Found {CollectionCount} different collections"); RetVal.AppendLine($"{CollectionLessCount} books have no collection assigned"); return(RetVal.ToString()); }
public List <Book> getBooks(int from, int to) { if (from < 0 || from >= Books.Count()) { from = 0; } if (to < 0 || to >= Books.Count()) { to = Books.Count() - 1; } return(Books.ToList().Skip(from) .Take(to - from + 1).ToList()); }
public string GetPurchaseLink(Book item) { item.CheckNotNull(nameof(item)); if (string.IsNullOrEmpty(item.Url) || Books.Count() > 3) { return(""); } else { return("<a href='{0}' target='_blank'>{1}</a>".FormatInvariant( item.Url, (item.Url.StartsWith("http://amzn.to", StringComparison.InvariantCultureIgnoreCase) || item.Url.Contains("amazon", StringComparison.InvariantCultureIgnoreCase)) ? "View on Amazon" : "View")); } }
private List <Book> GetFriendsBooks(List <Member> friends, List <Book> myBooks) { List <Guid> friendIds = friends.Select(m => m.Id).ToList(); List <Guid> myBookIds = myBooks.Select(b => b.Id).ToList(); return(db.CollectionBooks.Include("Collection") .Include("Book") .Where(cb => friendIds.Contains(cb.Collection.MemberId)) .Select(cb => cb.Book) .GroupBy(b => b.GoogleVolumeId, (googleId, Books) => new { Key = googleId, Count = Books.Count(), Value = Books.FirstOrDefault() }) .OrderByDescending(g => g.Count) .Select(g => g.Value) .AsEnumerable() .SkipWhile(b => myBookIds.Contains(b.Id)) .Take(5) .ToList()); }
private List <Book> GetRelatedBooks(Book book) { List <Guid> collectionIds = db.CollectionBooks.Include("Collection") .Where(cb => cb.BookId == book.Id) .Select(cb => cb.Collection.Id) .ToList(); return(db.CollectionBooks.Include("Book") .Where(cb => collectionIds.Contains(cb.CollectionId)) .Select(cb => cb.Book) .GroupBy(b => b.GoogleVolumeId, (googleId, Books) => new { Key = googleId, Count = Books.Count(), Value = Books.FirstOrDefault() }).OrderByDescending(g => g.Count) .Select(g => g.Value) .AsEnumerable() .SkipWhile(b => b.Id == book.Id) .Take(5) .ToList()); }
public void OnGet(int authorId) { Author = catalog.GetAuthorById(authorId); Books = catalog.GetBooksByAuthor(authorId); NumberOfBooks = Books.Count(); }
public Book AddBook(Book book) { book.Id = Books.Count() == 0 ? "1" : (Books.Max(b => Convert.ToInt32(b.Id)) + 1).ToString(); Books.Add(book); return(book); }
private void grdmain_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Left) { //check # of chapters in book //if last chapter get next book //back one chapter var prevChapter = (CurrentVerseSelection.curr.chapter - 1); if (prevChapter >= 1) { GoTo(CurrentVerseSelection.curr.book, prevChapter, 1); } else { var bookIndex = Books.FindIndex(x => x.abbrev == CurrentVerseSelection.curr.book) - 1; if (bookIndex >= 0) { var prevBook = Books[bookIndex]; GoTo(prevBook.abbrev, 1, 1); } } } if (e.Key == Key.Right) { var nextChapter = (CurrentVerseSelection.curr.chapter + 1); if (nextChapter <= Chapters.Count()) { GoTo(CurrentVerseSelection.curr.book, nextChapter, 1); } else { var bookIndex = Books.FindIndex(x => x.abbrev == CurrentVerseSelection.curr.book) + 1; if (bookIndex <= Books.Count()) { var nextBook = Books[bookIndex]; GoTo(nextBook.abbrev, 1, 1); } } } if (e.Key == Key.Up) { // back one verse if (CurrentVerseSelection.prev == null) { return; } GoTo(CurrentVerseSelection.curr.book, CurrentVerseSelection.curr.chapter, CurrentVerseSelection.prev.verse); SelectedChapter = CurrentVerseSelection.curr.chapter; SelectedVerse = CurrentVerseSelection.curr.verse; } if (e.Key == Key.Down) { if (CurrentVerseSelection.next == null) { return; } GoTo(CurrentVerseSelection.curr.book, CurrentVerseSelection.curr.chapter, CurrentVerseSelection.next.verse); SelectedChapter = CurrentVerseSelection.curr.chapter; SelectedVerse = CurrentVerseSelection.curr.verse; } }
public void AddBook(Book book) { book.Id = Books.Count() == 0 ? 1 : Books.Max(b => b.Id) + 1; Books.Add(book); }