Example #1
0
        private void DisplayInformationAboutTheLibrary()
        {
            Console.Clear();
            Console.WriteLine("The library has {0} books.", BooksList.Count);
            var groupedBooksByGenre = BooksList.GroupBy(book => book.Genere);

            foreach (var group in groupedBooksByGenre)
            {
                Console.WriteLine("There are {0} in genere {1}", group.Count(), group.Key);

                foreach (var book in group)
                {
                    Console.WriteLine(book);
                }
            }

            var theNewestBookYearOfPublication = BooksList.Max(book => book.YearOfPublication);
            var theNewestBooks = BooksList.Where(book => book.YearOfPublication == theNewestBookYearOfPublication);

            Console.WriteLine("The newest books are:");

            foreach (var book in theNewestBooks)
            {
                Console.WriteLine(book);
            }

            var theOldestBookYearOfPublication = BooksList.Min(book => book.YearOfPublication);
            var theOldestBooks = BooksList.Where(book => book.YearOfPublication == theOldestBookYearOfPublication);

            Console.WriteLine("The oldest books are:");

            foreach (var book in theOldestBooks)
            {
                Console.WriteLine(book);
            }

            var theMostPopularBookIndex = BooksList.Max(book => book.PopularityIndex);
            var theMostPopularBooks     = BooksList.Where(book => book.PopularityIndex == theMostPopularBookIndex);

            Console.WriteLine("The most popular books are:");

            foreach (var book in theMostPopularBooks)
            {
                Console.WriteLine(book);
            }

            var theMostUnPopularBookIndex = BooksList.Min(book => book.PopularityIndex);
            var theMostUnPopularBooks     = BooksList.Where(book => book.PopularityIndex == theMostUnPopularBookIndex);

            Console.WriteLine("The most unpopular books are:");

            foreach (var book in theMostUnPopularBooks)
            {
                Console.WriteLine(book);
            }

            Console.WriteLine("Please, press any key to continue...");
            Console.ReadLine();
        }
Example #2
0
        private void DisplayInformationAboutTheMostPopularBook()
        {
            Console.Clear();
            var groupedBooksByGenre = BooksList.GroupBy(book => book.Genere);

            foreach (var group in groupedBooksByGenre)
            {
                var theMostPopularBookIndex = group.Max(book => book.PopularityIndex);
                var theMostPopularBooks     = BooksList.Where(book => book.PopularityIndex == theMostPopularBookIndex);
                Console.WriteLine("The most popular books in genre {0} are:", group.Key);

                foreach (var book in theMostPopularBooks)
                {
                    Console.WriteLine(book);
                }
            }
        }
Example #3
0
        private void FindBooksByTheAuthor()
        {
            Console.Clear();
            Console.WriteLine("Please, print the book's author.");
            var author          = Console.ReadLine();
            var isAnyAuthorBook = BooksList.Any(book => book.Author == author && book.Count > 0);

            if (isAnyAuthorBook)
            {
                var findedBooks = BooksList.Where(book => book.Author == author && book.Count > 0);

                foreach (var findedBook in findedBooks)
                {
                    Console.WriteLine(findedBook);
                }
            }
            else
            {
                Console.WriteLine("There isn't any book of the author.");
            }
        }