Esempio n. 1
0
        private static void InitApp(Theatre theatre, Client client)
        {
            bool init = true;

            Console.WriteLine($"Welcome to the Royal Theatre of Arthur the Great, {client.Name}");
            while (init)
            {
                Console.WriteLine();
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("1: Search for the performance");
                Console.WriteLine("2: Look all the performances");
                Console.WriteLine("3: Check my balance");
                Console.WriteLine("4: Check all my tickets, that I've bought");
                Console.WriteLine("5: Check all my tickets, that I've booked");
                Console.WriteLine("6: Exit");
                Console.WriteLine();
                string choice = Console.ReadLine();
                switch (choice)
                {
                case "1":
                    Console.WriteLine();
                    Console.WriteLine("Here are 4 criteria, that you can use to search for a performance.");
                    Console.WriteLine("1: Name");
                    Console.WriteLine("2: Author");
                    Console.WriteLine("3: Genre");
                    Console.WriteLine("4: Date");
                    Console.WriteLine();
                    string criteria = Console.ReadLine();
                    switch (criteria)
                    {
                    case "1":
                        Console.WriteLine();
                        Console.WriteLine("Enter name query:");
                        Console.WriteLine();
                        string name = Console.ReadLine();
                        ProcessPerformances(theatre, client, theatre.FilterByName(name));
                        break;

                    case "2":
                        Console.WriteLine();
                        Console.WriteLine("Enter author query:");
                        Console.WriteLine();
                        string author = Console.ReadLine();
                        ProcessPerformances(theatre, client, theatre.FilterByAuthor(author));
                        break;

                    case "3":
                        Console.WriteLine();
                        Console.WriteLine("Enter genre query:");
                        Console.WriteLine();
                        string genre = Console.ReadLine();
                        ProcessPerformances(theatre, client, theatre.FilterByGenre(genre));
                        break;

                    case "4":
                        Console.WriteLine();
                        Console.WriteLine("Enter date query: (in format MM/DD/YYYY)");
                        Console.WriteLine();
                        string date = Console.ReadLine();
                        ProcessPerformances(theatre, client, theatre.FilterByDate(date));
                        break;

                    default:
                        Console.WriteLine(Constants.WrongChoice);
                        break;
                    }

                    break;

                case "2":
                    ProcessPerformances(theatre, client);
                    break;

                case "3":
                    Console.WriteLine();
                    Console.WriteLine($"Your balance is {client.Balance} ₴");
                    break;

                case "4":
                    Console.WriteLine();
                    Console.WriteLine("Here are tickets, that you already own:");
                    if (client.BoughtTickets().Count == 0)
                    {
                        Console.WriteLine(Constants.NoTicketsBought);
                    }
                    else
                    {
                        foreach (Ticket ticket in client.BoughtTickets())
                        {
                            Console.WriteLine(ticket + "\n" +
                                              $"To the {ticket.Performance.Name}," +
                                              $" that will be played on {ticket.Performance.Date}");
                        }
                    }

                    break;

                case "5":
                    Console.WriteLine();
                    Console.WriteLine("Here are tickets, that you only booked:");
                    if (client.BookedTickets().Count == 0)
                    {
                        Console.WriteLine(Constants.NoTicketsBooked);
                    }
                    else
                    {
                        foreach (Ticket ticket in client.BookedTickets())
                        {
                            Console.WriteLine(ticket + "\n" +
                                              $"To the {ticket.Performance.Name}," +
                                              $" that will be played on {ticket.Performance.Date}");
                        }
                    }

                    break;

                case "6":
                    init = false;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine(Constants.WrongChoice);
                    break;
                }
            }
        }