public static void Fix() { while (true) { Console.Clear(); BusesList.ShowAllBuses(); Console.Write("\n\nВведите номер автобуса: "); busNumberString = Console.ReadLine(); busNumberString = busNumberString.ExtractOnlyDigits(); if (busNumberString.IsDigits() == true) { Int32.TryParse(busNumberString, out busNumber); busRepository = new BusRepository(); busesQuantity = busRepository.Count(); if (busNumber > 0 && busNumber <= busesQuantity) { Console.Clear(); if (BusesList.ShowBusByNumber(busNumber) == true) { var allBuses = busRepository.GetAll(); var bus = allBuses.Skip(busNumber - 1).Take(1).ToList(); if (bus.FirstOrDefault().Status == "Сломан") { Console.WriteLine("\n"); MechanicsList.ShowAllMechanics(); Console.Write("\n\nВведите номер механика: "); mechanicNumberString = Console.ReadLine(); mechanicNumberString = mechanicNumberString.ExtractOnlyDigits(); if (mechanicNumberString.IsDigits() == true) { Int32.TryParse(mechanicNumberString, out mechanicNumber); mechanicsRepository = new MechanicsRepository(); mechanicsQuantity = mechanicsRepository.Count(); if (mechanicNumber > 0 && mechanicNumber <= mechanicsQuantity) { Console.Clear(); BusesList.ChangeStatusAndAddMechanic(mechanicNumber); Console.WriteLine($"Механик чинит автобус"); Console.ReadKey(); } } } else if (bus.FirstOrDefault().Status == "На ремонте") { Console.Write("\nАвтобус починили? 1 - Да, 2 - Нет: "); choiseString = Console.ReadLine(); choiseString = choiseString.ExtractOnlyDigits(); if (choiseString.IsDigits() == true) { Int32.TryParse(choiseString, out choise); if (choise == 1) { BusesList.ChangeStatusAndAddMechanic(); Console.WriteLine($"Автобус исправен"); Console.ReadKey(); } else if (choise == 2) { Console.WriteLine($"Автобус на ремонте"); Console.ReadKey(); } } } else { Console.WriteLine("Автобус исправен"); Console.ReadKey(); } } } else { Console.ReadKey(); } } } }