Beispiel #1
0
        public void ViewCatalogsAction()
        {
            _view.Show("Following catalogs was been created:");
            IList <Catalog> catalogs = ModelStorage.GetCatalogs();

            if (catalogs.Count != 0)
            {
                string[] viewString   = new string[catalogs.Count];
                string[] catalogsName = new string[catalogs.Count];
                int      lines        = 0;
                foreach (Catalog catalog in catalogs)
                {
                    viewString[lines]   = lines.ToString() + ". " + catalog.Name;
                    catalogsName[lines] = catalog.Name;
                    lines++;
                }

                _view.Show("Choose following catalogs");
                _view.Show(viewString);
                string chooseCatalog  = Console.ReadLine();
                Route  nextController = _routes.FirstOrDefault(b => b.Id == "5");
                redirect(nextController.Action, nextController.Controller, new object[] { catalogsName[Int32.Parse(chooseCatalog)] });
            }
            else
            {
                _view.Show(new string[] { "Catalogs doesnt exists",
                                          "Press 'Enter' to return" });
                Console.ReadLine();
                Route nextController = _routes.FirstOrDefault(b => b.Id == "back");
                redirect(nextController.Action, nextController.Controller, null);
            }
        }
Beispiel #2
0
        public void IndexAction()
        {
            IList <Catalog> catalogs = ModelStorage.GetCatalogs();

            if (catalogs.Count != 0)
            {
                _view.Show("Choose catalog to take book over");
                string[] viewString   = new string[catalogs.Count];
                string[] catalogsName = new string[catalogs.Count];
                int      lines        = 0;
                foreach (Catalog catalog in catalogs)
                {
                    viewString[lines]   = lines.ToString() + ". " + catalog.Name;
                    catalogsName[lines] = catalog.Name;
                    lines++;
                }

                _view.Show(viewString);
                _view.Show("Type 'menu' for return into menu");
                string chooseCatalog = Console.ReadLine();
                if (chooseCatalog == "menu")
                {
                    Route nextController = _routes.FirstOrDefault(b => b.Id == chooseCatalog);
                    redirect(nextController.Action, nextController.Controller);
                }
                else
                {
                    Route nextController = _routes.FirstOrDefault(b => b.Id == "catalog");
                    redirect(nextController.Action, nextController.Controller, new object[] { catalogsName[Int32.Parse(chooseCatalog)] });
                }
            }
            else
            {
                _view.Show("Catalogs doesnt exists");
                _view.Show("Press 'Enter' to return");
                Console.ReadLine();
                Route nextController = _routes.FirstOrDefault(b => b.Id == "menu");
                redirect(nextController.Action, nextController.Controller, null);
            }
        }