public void Sort_by_first_name_client_test()
        {
            Client_management.Add_client("Friedrich", "Nietzsche", "QQ784541", "9999999999");
            Client_management.Add_client("Gene", "Bloch", "MK784512", "8888888888");
            Client_management.Add_client("Brian", "Molko", "RE125122", "7777777777");

            Client_management.Sort_by_first_name();

            Assert.IsTrue(Client_management.clients[0].First_name == "Brian");
            Assert.IsTrue(Client_management.clients[1].First_name == "Friedrich");
            Assert.IsTrue(Client_management.clients[2].First_name == "Gene");
        }
        public void Add_client_test()
        {
            Client_management.Add_client("Gene", "Bloch", "MK784512", "8888888888");
            Client_management.Add_client("Brian", "Molko", "RE125122", "7777777777");

            Assert.IsTrue(Client_management.clients[1].First_name == "Brian");
            Assert.IsTrue(Client_management.clients[1].Last_name == "Molko");
            Assert.IsTrue(Client_management.clients[1].Passport == "RE125122");
            Assert.IsTrue(Client_management.clients[1].Phone_number == "7777777777");

            Client_management.Clear_clients_list();
        }
Exemple #3
0
        public void Order_test()
        {
            Hotel_management.Clear_hotels_list();
            Client_management.Clear_clients_list();

            Hotel_management.Add_hotel("Ukraine", 50, 100);
            Hotel_management.Make_order_request("Ukraine", 5, 2, "5555555555");
            Client_management.Add_client("Gene", "Bloch", "MK754645", "5555555555");

            Room_ordering_management.Order_room(0, "Ukraine", "5555555555");

            Assert.IsTrue(Hotel_management.Find("Ukraine").approved_orders[0].Client.Passport == "MK754645");
        }
Exemple #4
0
        private static void Client_management_menu()
        {
            Console.Clear();
            Console.WriteLine("Client management");
            Console.WriteLine("\t1 - Add client");
            Console.WriteLine("\t2 - Remove client");
            Console.WriteLine("\t3 - Change client info");
            Console.WriteLine("\t4 - Show info about a client");
            Console.WriteLine("\t5 - Show info about all clients");
            Console.WriteLine("\t6 - Sort client by firt name");
            Console.WriteLine("\t7 - Sort client by last name");
            Console.WriteLine("\t8 - Search by first name");
            Console.WriteLine("\t9 - Search by last name");
            Console.WriteLine("\t0 - Turn back to main menu");

            try
            {
                int command = int.Parse(Console.ReadLine());

                switch (command)
                {
                case 0:
                    Main_menu();
                    break;

                case 1:
                    Console.Clear();
                    Console.Write("First name: ");
                    string first_name = Check.Check_value(Console.ReadLine(), first_name_regex);

                    Console.Write("Last name: ");
                    string last_name = Check.Check_value(Console.ReadLine(), last_name_regex);

                    Console.Write("Passport: ");
                    string passport = Check.Check_value(Console.ReadLine(), passport_regex);

                    Console.Write("Phone number: ");
                    string phone_number = Check.Check_value(Console.ReadLine(), phone_number_regex);

                    if (first_name != "" && last_name != "" && passport != "" && phone_number != "" &&
                        Client_management.Is_unique_passport(passport) && Client_management.Is_unique_phone_number(phone_number))
                    {
                        Client_management.Add_client(first_name, last_name, passport, phone_number);
                        Console.WriteLine("Successfully added");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 2:
                    Console.Clear();
                    Console.Write("Passport: ");
                    passport = Check.Check_value(Console.ReadLine(), passport_regex);

                    if (passport != "")
                    {
                        Client_management.Remove_client(passport);
                        Console.WriteLine("Successfully removed");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 3:
                    Console.Clear();
                    Client_management.Info_about_all_clients();

                    Console.Write("\nClient id: ");
                    int id = int.Parse(Console.ReadLine());

                    Console.Write("New first name: ");
                    first_name = Check.Check_value(Console.ReadLine(), first_name_regex);

                    Console.Write("New last name: ");
                    last_name = Check.Check_value(Console.ReadLine(), last_name_regex);

                    Console.Write("New passport: ");
                    passport = Check.Check_value(Console.ReadLine(), passport_regex);

                    Console.Write("New phone number: ");
                    phone_number = Check.Check_value(Console.ReadLine(), phone_number_regex);

                    if (id.ToString() != "" && first_name != "" && last_name != "" && passport != "" && phone_number != "" &&
                        Client_management.Is_unique_passport(passport) && Client_management.Is_unique_phone_number(phone_number))
                    {
                        Client_management.Change_client_info(id, first_name, last_name, passport, phone_number);
                        Console.WriteLine("Successfully changed");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 4:
                    Console.Clear();
                    Console.Write("Passport: ");
                    passport = Check.Check_value(Console.ReadLine(), passport_regex);

                    Console.Clear();

                    if (passport != "")
                    {
                        Client_management.Client_info(passport);
                    }
                    else
                    {
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 5:
                    Console.Clear();

                    if (Client_management.clients.Count == 0)
                    {
                        Console.WriteLine("There are no clients");
                    }
                    else
                    {
                        Client_management.Info_about_all_clients();
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 6:
                    Console.Clear();
                    Client_management.Sort_by_first_name();

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 7:
                    Console.Clear();
                    Client_management.Sort_by_last_name();

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 8:
                    Console.Clear();
                    Console.Write("First name: ");
                    first_name = Check.Check_value(Console.ReadLine(), first_name_regex);

                    Console.Clear();

                    if (first_name != "")
                    {
                        int i = 0;
                        while (i < Client_management.Search_by_first_name(first_name).Count)
                        {
                            Client c = Client_management.Search_by_first_name(first_name)[i];
                            Client_management.Client_info(c);

                            if (i != Client_management.Search_by_first_name(first_name).Count - 1)
                            {
                                Console.WriteLine("- - - - - - - - - -");
                            }

                            i++;
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                case 9:
                    Console.Clear();
                    Console.Write("Last name: ");
                    last_name = Check.Check_value(Console.ReadLine(), last_name_regex);

                    Console.Clear();

                    if (last_name != "")
                    {
                        int j = 0;
                        while (j < Client_management.Search_by_last_name(last_name).Count)
                        {
                            Client c = Client_management.Search_by_last_name(last_name)[j];
                            Client_management.Client_info(c);

                            if (j != Client_management.Search_by_last_name(last_name).Count - 1)
                            {
                                Console.WriteLine("- - - - - - - - - -");
                            }

                            j++;
                        }
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect input");
                    }

                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    Client_management_menu();
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine("Invalid input");
                    Console.ReadKey();
                    break;
                }
            }
            catch
            {
                Console.WriteLine("ERROR");
                Console.ReadKey();
            }
        }