public void Remove_order_request_test() { Hotel_management.Clear_hotels_list(); Hotel_management.Clear_order_requests_list(); Hotel_management.Add_hotel("Royal", 50, 20); Hotel_management.Make_order_request("Royal", 10, 5, "7777777777"); Hotel_management.Make_order_request("Royal", 15, 1, "4444444444"); Hotel_management.Remove_order_request("Royal", 10); Assert.AreEqual(Hotel_management.Find("Royal").order_requests[0].Phone_number_for_request, "4444444444"); Assert.AreEqual(Hotel_management.Find("Royal").order_requests[0].Room_number, 15); Assert.AreEqual(Hotel_management.Find("Royal").order_requests[0].Days_amount, 1); }
private static void Hotel_management_menu() { Console.Clear(); Console.WriteLine("Hotel management"); Console.WriteLine("\t1 - Add hotel"); Console.WriteLine("\t2 - Remove hotel"); Console.WriteLine("\t3 - Show info about a hotel"); Console.WriteLine("\t4 - Show info about all hotels"); Console.WriteLine("\t5 - Make order request"); Console.WriteLine("\t6 - Remove order request"); Console.WriteLine("\t7 - Change order request"); Console.WriteLine("\t8 - Show order requests"); Console.WriteLine("\t9 - Search by name"); Console.WriteLine("\t10 - Search by price"); 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("Hotel name: "); string name = Check.Check_value(Console.ReadLine(), hotel_name_regex); Console.Write("Rooms amount: "); int rooms_amount = int.Parse(Console.ReadLine()); Console.Write("Price per day: "); int price_per_day = int.Parse(Console.ReadLine()); if (name != "" && Hotel_management.Is_unique_name(name)) { Hotel_management.Add_hotel(name, rooms_amount, price_per_day); Console.WriteLine("Successfully added"); } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 2: Console.Clear(); Console.Write("Hotel name: "); string hotel_to_remove = Check.Check_value(Console.ReadLine(), hotel_name_regex); if (hotel_to_remove != "") { Hotel_management.Remove_hotel(hotel_to_remove); Console.WriteLine("Successfully removed"); } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 3: Console.Clear(); Console.Write("Hotel name: "); name = Check.Check_value(Console.ReadLine(), hotel_name_regex); Console.Clear(); if (name != "") { Hotel_management.Hotel_info(name); } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 4: Console.Clear(); if (Hotel_management.hotels.Count == 0) { Console.WriteLine("Hotels list is empty"); } else { Hotel_management.Info_about_all_hotels(); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 5: Console.Clear(); Console.Write("Hotel name: "); name = Check.Check_value(Console.ReadLine(), hotel_name_regex); Console.Write("Room number: "); int room_number = int.Parse(Console.ReadLine()); Console.Write("Days amount: "); int days_amount = int.Parse(Console.ReadLine()); Console.Write("Client phone number: "); string client_phone_number = Check.Check_value(Console.ReadLine(), phone_number_regex); if (name != "" && client_phone_number != "") { Hotel_management.Make_order_request(name, room_number, days_amount, client_phone_number); Console.WriteLine("Order request was successfully sent"); } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 6: Console.Clear(); Console.Write("Hotel name: "); name = Check.Check_value(Console.ReadLine(), hotel_name_regex); Console.Write("Room number: "); room_number = int.Parse(Console.ReadLine()); if (name != "") { Hotel_management.Remove_order_request(name, room_number); Console.WriteLine("Order request was successfully removed"); } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 7: Console.Clear(); Console.Write("Hotel name: "); name = Check.Check_value(Console.ReadLine(), hotel_name_regex); Console.Write("Old room number: "); int old_room_number = int.Parse(Console.ReadLine()); Console.Write("New room number: "); int new_room_number = int.Parse(Console.ReadLine()); Console.Write("Days amount: "); days_amount = int.Parse(Console.ReadLine()); Console.Write("Client phone number: "); client_phone_number = Check.Check_value(Console.ReadLine(), phone_number_regex); if (name != "" && client_phone_number != "") { Hotel_management.Change_order_request(name, old_room_number, new_room_number, days_amount, client_phone_number); Console.WriteLine("Order request was successfully changed"); } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 8: Console.Clear(); Console.Write("Hotel name: "); name = Check.Check_value(Console.ReadLine(), hotel_name_regex); Console.Clear(); if (name != "") { if (Hotel_management.Find(name).order_requests.Count == 0) { Console.WriteLine("There are no order requests for the hotel"); } else { Hotel_management.Show_order_requests(name); } } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 9: Console.Clear(); Console.Write("Hotel name: "); name = Check.Check_value(Console.ReadLine(), hotel_name_regex); Console.Clear(); if (name != "") { Hotel_management.Hotel_info(Hotel_management.Search(name)); } else { Console.Clear(); Console.WriteLine("Incorrect input"); } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; case 10: Console.Clear(); Console.Write("Price per day: "); price_per_day = int.Parse(Console.ReadLine()); Console.Clear(); int i = 0; while (i < Hotel_management.Search(price_per_day).Count) { Hotel h = Hotel_management.Search(price_per_day)[i]; Hotel_management.Hotel_info(h); if (i != Hotel_management.Search(price_per_day).Count - 1) { Console.WriteLine("- - - - - - - - - -"); } i++; } Console.WriteLine("Press any key to continue"); Console.ReadKey(); Hotel_management_menu(); break; default: Console.WriteLine("Invalid input"); Console.ReadKey(); break; } } catch { Console.WriteLine("ERROR"); Console.ReadKey(); } }