Пример #1
0
        public void AddBookMenu()
        {
            Console.Clear();
            Console.WriteLine("Enter publishing year");
            string _year = Console.ReadLine();

            if (int.TryParse(_year, out int year))
            {
                Console.WriteLine("Enter book title");
                var name = Console.ReadLine().Replace(@"/", @"\");
                Console.WriteLine("Enter book author");
                var author = Console.ReadLine().Replace(@"/", @"\");
                Console.WriteLine("Enter book isbn");
                var isbn    = Console.ReadLine().Replace(@"/", @"\");
                var newBook = new BookModel(year, name, author, isbn);
                var choise  = ConsoleMenu.MultipleChoice(false, "[  update db  ]", "[ back to main ]");

                switch (choise)
                {
                case 0:
                {
                    this.dataProvider.Books.AddBook(newBook, true);
                    this.dataProvider.WriteToLibrary();
                    Logger.PrintMessage("Book added");
                }
                break;

                case 1:
                {
                    break;
                }
                }
            }
            else
            {
                Logger.PrintError("Wrong publishing year format");
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            InitializeDB(args);

            IBookLib      books        = new BookLib();
            ILibManager   libManager   = new LibManager(Settings.LibraryFile);
            IDataProvider dataProvider = new DataProvider(libManager, books);

            var menu = new Menu(libManager, dataProvider);

            while (true)
            {
                var choise = ConsoleMenu.MultipleChoice(true, "[ Add new book ]", "[ Open library ]", "[     Quit     ]");

                switch (choise)
                {
                case 0:
                {
                    menu.AddBookMenu();
                }
                break;

                case 1:
                {
                    menu.ShowLib();
                }
                break;

                case 2:
                {
                    menu.Quit();
                }
                break;
                }
            }
        }