public IActionResult Index() { var viewModel = new BusIndexViewModel(); viewModel.Buses = mapper.Map <List <BusViewModel> >(busRepository.GetAll()); viewModel.BusRouteList = mapper.Map <List <BusRouteViewModel> >(busRouteRepository.GetAll()); return(View(viewModel)); }
public void RefreshSeats() { if (binSourceBusStation.Count != 0) { flight = binSourceBusStation.Current as BusinessFlights; if (flight.CityStart != null) { DateTime dt = DateTime.Now.Date; cbSeats.DataSource = null; BusStationEntities conect = new BusStationEntities(); BusRepository busrep = new BusRepository(); BusinessTicketsRepository btr = new BusinessTicketsRepository(); string BussName = flight.Bus; dt = flight.DepartureDate; int Busid = busrep.GetAll().Where(p => p.BusName == BussName).Select(p => p.BusId).First(); var notSeats = conect.Tickets.Where(p => p.Flights.DepartureDate == dt && p.Flights.BusId == Busid).Select(p => p.SeatId).ToList(); int count = 0; cbSeats.ValueMember = "SeatId"; cbSeats.DisplayMember = "NumberSeat"; var tempSeats = Seatsr.GetAll().Where(p => p.BusId == Busid).ToList(); while (count < notSeats.Count) { tempSeats = tempSeats.Where(p => p.SeatId != notSeats[count]).ToList(); count++; } cbSeats.DataSource = tempSeats; } else { MessageBox.Show("Выберите рейс"); } } }
private void RefreshcbBuses() { CitiRepository cityRep = new CitiRepository(); RefreshBindingSourse(); dtpDepartureDate.MinDate = DateTime.Now; dtpArrivalDate.MinDate = DateTime.Now; dtpFinalDateFlight.MinDate = DateTime.Now; cbCityStart.DisplayMember = "CityName"; cbCityStart.ValueMember = "CityId"; cbCityStart.DataSource = cityRep.GetAll(); cbCityEnd.DisplayMember = "CityName"; cbCityEnd.ValueMember = "CityId"; cbCityEnd.DataSource = cityRep.GetAll(); BusRepository busRep = new BusRepository(); FlightRepository flightRep = new FlightRepository(); var busybus = flightRep.GetAll().Select(p => p.BusId).ToList(); int count = 0; var tempBuses = busRep.GetAll(); while (count < busybus.Count) { tempBuses = tempBuses.Where(p => p.BusId != busybus[count]).ToList(); count++; } cbBuses.DisplayMember = "BusName"; cbBuses.ValueMember = "BusId"; cbBuses.DataSource = tempBuses; }
public IActionResult ManageBus() { var buses = busRepository.GetAll(); var viewModel = new BusManageViewModel(); foreach (var bus in buses) { var model = mapper.Map <BusViewModel>(bus); viewModel.Buses.Add(model); } return(View(viewModel)); }
public IActionResult Index() { var viewModels = _busRepository.GetAll() .Select(x => new BusParkViewModel() { Model = x.Model, Type = x.Type, Capacity = x.Capacity, Price = x.Price }).ToList(); return(View(viewModels)); }
public static bool ShowBusByNumber(int busNumber) { busRepository = new BusRepository(); var allBuses = busRepository.GetAll(); var bus = allBuses.Skip(busNumber - 1).Take(1).ToList(); if (bus.FirstOrDefault().Status != "Исправлен") { Console.WriteLine($"{bus.FirstOrDefault().Numberplate}({bus.FirstOrDefault().BusNumber})"); Console.WriteLine($"Статус: {bus.FirstOrDefault().Status}"); busId = bus.FirstOrDefault().Id; return(true); } else { Console.WriteLine("Вы не можете выбрать данный автобус."); return(false); } }
public IHttpActionResult GetSalesPerBus(int id) { Dictionary <string, double> keyValuePairs = new Dictionary <string, double>(); BookingRepository bookingRepository = new BookingRepository(); var bookings = bookingRepository.GetAll().Where(b => b.Trip.Bus.VendorId == 1); BusRepository busRepository = new BusRepository(); var buses = busRepository.GetAll().Where(b => b.VendorId == 1); List <string> busList = new List <string>(); List <double> earning = new List <double>(); foreach (var bus in buses) { var b = bus.BusName + "[" + bus.BusId.ToString() + "]"; var d = 0.0; var trp = bus.Trips; foreach (var t in trp) { int pti = t.Bookings.Where(x => x.SeatStatus != "reserved").ToList().Count; d += pti * t.Bus.PerSeatFair; } //busList.Add(b); //earning.Add(d); keyValuePairs.Add(b, d); } var ordered = keyValuePairs.OrderByDescending(x => x.Value).Take(10).ToDictionary(x => x.Key, x => x.Value); int n = ordered.Count < 3 ? ordered.Count : 3; for (int i = 0; i < n; i++) { busList.Add(ordered.Keys.ElementAt(i)); earning.Add(ordered.Values.ElementAt(i)); } return(Ok(new { busList, earning })); }
static void ShowBusesInfo() { var buses = busRepository.GetAll(); int num = 1; foreach (var bus in buses) { if (bus.Status == "Repair") { var mechId = serviceRepository.GetMechanicId(bus.Id); var mechName = mechanicRepository.GetById(mechId).Name; Console.WriteLine($"{num++}) Автобус номер {bus.Num} - Статус {bus.Status} - Механик {mechName}"); } else { Console.WriteLine($"{num++}) Автобус номер {bus.Num} - Статус {bus.Status}"); } } Console.ReadLine(); }
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}"); } } } }
// GET api/server public IEnumerable <Bus> Get() { return(db.GetAll()); }
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(); } } } }