private static void FillAllTables() { MechanicsRepository mechanicsRepository = new MechanicsRepository(); mechanicsRepository.Add(firstMechanic); mechanicsRepository.Add(secondMechanic); BusRepository busRepository = new BusRepository(); busRepository.Add(firstBus); busRepository.Add(secondBus); busRepository.Add(thirdBus); }
public static void ChangeStatusAndAddMechanic(int mechanicNumber) { mechanicsRepository = new MechanicsRepository(); var allMechanics = mechanicsRepository.GetAll(); var mechanic = allMechanics.Skip(mechanicNumber - 1).Take(1).ToList(); Buse bus = new Buse { Id = busId, MechanicId = mechanic.FirstOrDefault().Id, Status = "На ремонте" }; busRepository = new BusRepository(); busRepository.Update(bus); }
public static void ShowAllMechanics() { mechanicsRepository = new MechanicsRepository(); var allMechanics = mechanicsRepository.GetAll(); if (allMechanics.Count > 0) { Console.WriteLine("\t- Механики -\n"); int i = 1; foreach (var mechanic in allMechanics) { Console.WriteLine($"{i}. {mechanic.FullName}"); i++; } } }
public static void ShowAllBuses() { busRepository = new BusRepository(); var allBuses = busRepository.GetAll(); if (allBuses.Count > 0) { Console.WriteLine("\t- Автобусы -\n"); int i = 1; foreach (var bus in allBuses) { Console.WriteLine($"\n{i}. {bus.Numberplate}({bus.BusNumber})"); i++; Console.WriteLine($"Статус: {bus.Status}"); if (bus.Status == "На ремонте") { mechanicsRepository = new MechanicsRepository(); var allMechanics = mechanicsRepository.GetAll(); var mechanic = allMechanics.Where(m => m.Id.Equals(bus.MechanicId)).ToList(); Console.WriteLine($"Механик: {mechanic.FirstOrDefault().FullName}"); } } } }
public MechanicsController() { _mechanicsRepository = new MechanicsRepository(); }
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(); } } } }