Ejemplo n.º 1
0
        public void ViewBookAction(string book, IBookStorage catalog)
        {
            Book currentBook = catalog.GetByName(book);

            string[] viewString = { $"Book name:{currentBook.Name}",
                                    $"Book page:{currentBook.Pages}",
                                    $"Book Author:{currentBook.Author}",
                                    $"Book binding:{currentBook.Binding}",
                                    $"Book weight:{currentBook.Weight}",
                                    $"Book price:{currentBook.Price}",
                                    $"Book text:{currentBook.Text}",
                                    $"Book description:{currentBook.GetDescription()}" };
            _view.Show(viewString);
            _view.Show(new string[] { "Type 'Delete' for deleting book",
                                      "Type 'sell', to sell the book",
                                      "Type 'find' to find info from text in the book",
                                      "Type 'back' to return back" });
            string command = Console.ReadLine();

            switch (command)
            {
            case "Delete":
                catalog.DeleteBook(currentBook);
                _view.Show("Current book was deleted, press Enter to return back");
                break;

            case "find":
                _view.Show("Type word to search:");
                string word = Console.ReadLine();
                _view.Show(new string[] { currentBook.SearchInfo(word),
                                          "press Enter to return back" });
                break;

            case "sell":
                Sales sales = ModelStorage.GetSales();
                sales.AddBook(currentBook);
                catalog.DeleteBook(currentBook);
                _view.Show(new string[] { $"Book {currentBook.Name} was sold",
                                          "press Enter to return back" });
                break;

            default:
                break;
            }
            Console.ReadLine();
            Route nextController = _routes.FirstOrDefault(b => b.Id == "back");

            redirect(nextController.Action, nextController.Controller, null);
        }