Esempio n. 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();
        }