示例#1
0
        public static void DeleteBook()
        {
            var endSearch = true;

            while (endSearch)
            {
                Console.Clear();
                Console.WriteLine("This option is to delete a book. Please enter a keyword to search: ");
                var bookSearch = Console.ReadLine();

                var BooksSearchResult = bookService.SearchBooks(bookSearch);

                if (BooksSearchResult.Count == 0)
                {
                    Console.WriteLine("No results found.");
                }
                else
                {
                    Console.WriteLine("Results found!");
                    foreach (var book in BooksSearchResult)
                    {
                        PrintBookDetails(book);
                        Console.WriteLine("Would you like to delete this book? (y/n) ");
                        if (Console.ReadLine() == "y")
                        {
                            bookService.DeleteBook(book.BookId);

                            Console.WriteLine("Book Deleted!");
                        }
                    }
                }
                Console.WriteLine("Would you like to search for another book(y/n)?");
                if (Console.ReadLine() != "y")
                {
                    endSearch = false;
                }
            }
        }