예제 #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);
            }
        }
예제 #2
0
        public void ViewCatalogAction(string catalogName)
        {
            _view.Show("Current catalog: " + catalogName);
            Catalog currentCatalog = ModelStorage.GetBookStorage(catalogName);

            if (currentCatalog.GetBooks().Count == 0)
            {
                _view.Show("Catalog doesnt have any books");
            }
            else
            {
                _view.Show("Catalog have following books:");
                foreach (IBook book in currentCatalog.GetBooks())
                {
                    _view.Show(book.Name);
                }
            }

            _view.Show(new string[] { "Type book name to show the info",
                                      "Type 'add' for adding book into catalog" });
            string command = Console.ReadLine();

            if (command == "add")
            {
                Route nextController = _routes.FirstOrDefault(b => b.Id == "add");
                redirect(nextController.Action, nextController.Controller, new object[] { currentCatalog });
            }
            else
            {
                Route nextController = _routes.FirstOrDefault(b => b.Id == "book");
                redirect(nextController.Action, nextController.Controller, new object[] { command, currentCatalog });
            }
        }