Exemple #1
0
        public ICollection <Book> GetAvailableBooksSorted()
        {
            var allBooks = _readerWriter.GetBooks();

            ICollection <Book> availableBooks = new List <Book>();

            foreach (Book book in allBooks)
            {
                foreach (BookCopy bookCopy in book.Copies)
                {
                    if (bookCopy.LastReturnDate != null && !availableBooks.Contains(book))
                    {
                        availableBooks.Add(book);
                    }
                }
            }
            ICollection <Book> sortedAvailableBooks = availableBooks.OrderBy(o => o.Author).ToList();

            return(sortedAvailableBooks);
        }