public void IndexAction()
        {
            Sales sales = ModelStorage.GetSales();

            _view.Show(new string[] { $"Total sallary = {sales.GetTotalSallary()}",
                                      $"type 'view' to watch all saled books",
                                      $"type 'menu' to back to the menu" });
            string command        = Console.ReadLine();
            Route  nextController = _routes.FirstOrDefault(b => b.Id == command);

            redirect(nextController.Action, nextController.Controller, null);
        }
Exemple #2
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);
        }
        public void ViewAction()
        {
            Sales sales = ModelStorage.GetSales();

            if (sales.GetBooks().Count != 0)
            {
                _view.Show("Following books was selled:");
                foreach (Book book in sales.GetBooks())
                {
                    _view.Show(book.Name);
                }
            }
            else
            {
                _view.Show("None of the books was selled");
            }

            _view.Show("type 'menu' to return on the menu");
            string command        = Console.ReadLine();
            Route  nextController = _routes.FirstOrDefault(b => b.Id == command);

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