コード例 #1
0
        public void CatalogViewAction(string catalogName)
        {
            Catalog currentCatalog = ModelStorage.GetBookStorage(catalogName);

            if (currentCatalog.GetBooks().Count == 0)
            {
                _view.Show(new string[] { "This catalog doesn't have any books.",
                                          "Press 'Enter' to return" });
                Console.ReadLine();
                Route nextController = _routes.FirstOrDefault(b => b.Id == "index");
                redirect(nextController.Action, nextController.Controller, null);
            }
            else
            {
                _view.Show("Catalog have following books:");
                foreach (IBook book in currentCatalog.GetBooks())
                {
                    _view.Show(book.Name);
                }
                _view.Show(new string[] { "Type name of the book, to collect it into tablestand",
                                          "Type 'menu' to return to the menu" });
                string     bookName   = Console.ReadLine();
                Book       removeBook = currentCatalog.GetByName(bookName);
                TableStand wastepaper = ModelStorage.GetTablestand();
                _view.Show(wastepaper.AddBook(removeBook));
                currentCatalog.DeleteBook(removeBook);
                _view.Show("Press 'Enter' to return");
                Console.ReadLine();
                Route nextController = _routes.FirstOrDefault(b => b.Id == "index");
                redirect(nextController.Action, nextController.Controller, null);
            }
        }