Beispiel #1
0
        public static void ProceedToGetReader()
        {
            string username;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("----GET READER OF BOOK----" + "\n" + "\n" + ">Type your username");
                username = Console.ReadLine();
                if (!username.Trim().Equals(string.Empty))
                {
                    break;
                }
            }

            Admin admin = rental.TryPickAdminByUsername(username);

            if (admin == null)
            {
                NoAdminCase();
                return;
            }

            Console.Clear();
            Console.WriteLine("----GET READER OF BOOK----" + "\n" + "\n" + "Hi, Admin " + admin.Name + ", id: " + admin.Id);
            Dictionary <Book, Reader> result = rental.GetRentBooks();

            Console.WriteLine(result.Count != 0 ? "Rent books: " : "No rent books");
            if (result.Count != 0)
            {
                foreach (Book book in result.Keys)
                {
                    Console.WriteLine("Book: " + book.Name + "(id: " + book.Id + ") | Reader: " + result[book].Name + "(id: " + result[book].Id + ")");
                }

                Console.WriteLine("Type book id: ");
                Guid bookid = Guid.Parse(Console.ReadLine());
                Book b      = rental.TryGetBookById(bookid);
                if (b == null)
                {
                    Console.Clear();
                    Console.WriteLine("----RETURN BOOK----" + "\n" + "\n" + "No such book" + "\n" + "\n" + "Press any key to proceed...");
                    while (true)
                    {
                        if (Console.ReadKey() != null)
                        {
                            break;
                        }
                    }

                    return;
                }

                Reader reader = rental.TryGetReader(b);
                Console.WriteLine("_________" + "\n" + "Reader of " + b.Name + "(id: " + b.Id + ") is " + reader.Name + "(id: " + reader.Id + ")");
            }


            Console.WriteLine("\n" + "Press any key to proceed to menu...");
            while (true)
            {
                if (Console.ReadKey() != null)
                {
                    break;
                }
            }
        }