Beispiel #1
0
        public void Run()
        {
            while (true)
            {
                DisplayMenu();
                int choice = ReadChoice();

                switch (choice)
                {
                case 1:
                    Console.ForegroundColor = ConsoleColor.Blue;
                    _userServices.AddReader();
                    ScreenPause();
                    log.Info("A new reader has been added.");
                    break;

                case 2:
                    Console.ForegroundColor = ConsoleColor.Blue;
                    _userServices.AddLibrarian();
                    ScreenPause();
                    log.Info("A new librarian has been added.");
                    break;

                case 3:
                    Console.ForegroundColor = ConsoleColor.DarkBlue;
                    _domainServices.AddDomain();
                    ScreenPause();
                    log.Info("A new domain has been added.");
                    break;

                case 4:
                    Console.ForegroundColor = ConsoleColor.DarkBlue;
                    _domainServices.AddSubdomain();
                    ScreenPause();
                    log.Info("A new subdomain has been added.");
                    break;

                case 5:
                    Console.ForegroundColor = ConsoleColor.DarkCyan;
                    _editionServices.AddEdition();
                    ScreenPause();
                    log.Info("A new edition has been added.");
                    break;

                case 6:
                    Console.ForegroundColor = ConsoleColor.Red;
                    _editionServices.AddAuthorForEdition();
                    ScreenPause();
                    log.Info("A new author has been added for an edition.");
                    break;

                case 7:
                    Console.ForegroundColor = ConsoleColor.Red;
                    _bookServices.AddDomainForBook();
                    ScreenPause();
                    log.Info("A book has been added in a new domain.");
                    break;

                case 8:
                    Console.ForegroundColor = ConsoleColor.Red;
                    _editionServices.BorrowEdition();
                    ScreenPause();
                    log.Info("An edition has been borrowed.");
                    break;

                case 9:
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    List <Edition> books = _editionServices.GetEditionsAlphabetical();
                    Display(books);
                    ScreenPause();
                    log.Info("All editions have been displayed alphabeticaly.");
                    break;

                case 10:
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    List <Edition> borrowedBooks = _editionServices.GetBorrowedEditionsAlphabetical();
                    Display(borrowedBooks);
                    ScreenPause();
                    log.Info("All borrowed editions have been displayed alphabeticaly.");
                    break;

                case 11:
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    List <Author> authors = _editionServices.GetAuthorsForEdition();
                    if (authors != null)
                    {
                        Display(authors);
                    }

                    ScreenPause();
                    log.Info("All authors for an edition have been displayed.");
                    break;

                case 12:
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    List <User> librarians = _userServices.GetLibrarians();
                    Display(librarians);
                    ScreenPause();
                    log.Info("All librarians have been displayed.");
                    break;

                case 13:
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    List <User> readers = _userServices.GetReaders();
                    Display(readers);
                    ScreenPause();
                    log.Info("All readers have been displayed.");
                    break;

                case 14:
                    Console.ForegroundColor = ConsoleColor.DarkBlue;
                    List <Domain> domains = _domainServices.GetDomains();
                    Display(domains);
                    ScreenPause();
                    log.Info("All domains have been displayed.");
                    break;

                case 15:
                    Console.ForegroundColor = ConsoleColor.DarkBlue;
                    List <Domain> domainsForBook = _bookServices.GetDomainsForBook();
                    if (domainsForBook != null)
                    {
                        Display(domainsForBook);
                    }

                    log.Info("All domains for one book have been displayed.");
                    ScreenPause();
                    break;

                case 16:
                    Console.ForegroundColor = ConsoleColor.DarkBlue;
                    List <Borrow> borrows = _borrowServices.GetBorrowsForUser();
                    if (borrows != null)
                    {
                        Display(borrows);
                    }

                    log.Info("All borrowed edition for one user have been displayed.");
                    ScreenPause();
                    break;

                case Exit:
                    Console.WriteLine("\n Bye-bye! :)");
                    return;
                }
            }
        }