public async Task <ActionResult> MaintenanceFormsCreation(MaintenanceModel maintenance) { BusModel bus; MaintenanceRepository repo = new MaintenanceRepository(configModel.ConnectionString); BusRepository busRepo = new BusRepository(configModel.ConnectionString); VolunteerRepository volunteerRepo = new VolunteerRepository(configModel.ConnectionString); var user = await userManager.GetUserAsync(User); VolunteerModel profile; if (user == null || !User.IsInRole(UserHelpers.UserRoles.BusDriver.ToString())) { return(Utilities.ErrorJson("Not authorized")); } bus = busRepo.GetBus(maintenance.BusId); if (bus == null) { return(Utilities.ErrorJson("Invalid bus id")); } if (String.IsNullOrEmpty(maintenance.Text)) { return(Utilities.ErrorJson("Text cannot be empty")); } profile = volunteerRepo.GetVolunteer(user.VolunteerId); repo.CreateMaintenanceForm(maintenance.BusId, maintenance.Text, profile.PreferredName + " " + profile.LastName); return(Utilities.NoErrorJson()); }
public ActionResult Index() { IEnumerable <Bus> list = BusRepository.TestBusList(); IEnumerable <Customer> userList = busRepository.UserDetailDisplay(); return(View(userList)); }
public async Task <ActionResult> UserInfo() { VolunteerRepository repo = new VolunteerRepository(configModel.ConnectionString); CalendarRepository calendarRepo = new CalendarRepository(configModel.ConnectionString); ClassRepository classRepo = new ClassRepository(configModel.ConnectionString); BusRepository busRepo = new BusRepository(configModel.ConnectionString); AttendanceModel attendance; VolunteerModel profile; var user = await userManager.GetUserAsync(User); bool checkedIn = false; List <ClassModel> classes = new List <ClassModel>(); List <BusModel> buses = new List <BusModel>(); // Get the current user's profile try { profile = repo.GetVolunteer(user.VolunteerId); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } if (profile == null) { return(Utilities.ErrorJson("Could not find user profile")); } if (configModel.DebugMode || DateTime.Now.DayOfWeek == DayOfWeek.Saturday) { try { attendance = calendarRepo.GetSingleAttendance(profile.Id, DateTime.Now.Date); // determine if the current user has been checked in today if (attendance != null && attendance.Attended == true) { checkedIn = true; } // Get the classes the user teaches and buses the user drives classes = classRepo.GetClasses(true).Where(c => c.TeacherId == profile.Id).ToList(); buses = busRepo.GetBusList(true).Where(b => b.DriverId == profile.Id).ToList(); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } } return(new JsonResult(new { Error = "", Profile = profile, CheckedIn = checkedIn, Classes = classes, Buses = buses })); }
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 async Task <IActionResult> BusEdit(BusModel model) { BusRepository repo = new BusRepository(configModel.ConnectionString); BusModel bus; var user = await userManager.GetUserAsync(User); // Make sure the user is a maintenance worker if (!await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.BusMaintenance.ToString())) { return(Utilities.ErrorJson("Unauthorized")); } // Validate the input bus = repo.GetBus(model.Id); if (bus == null) { return(Utilities.ErrorJson("Invalid bus id")); } try { repo.UpdateBus(model.Id, model.LastMaintenance, model.LastOilChange, model.LastTireChange); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(Utilities.NoErrorJson()); }
public async Task <IActionResult> BusCreation(BusModel bus) { var user = await userManager.GetUserAsync(User); BusRepository busRepo = new BusRepository(configModel.ConnectionString); // Ensure that ONLY staff accounts have access to this API endpoint if (user == null || !await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString())) { return(Utilities.ErrorJson("Not authorized")); } if (string.IsNullOrEmpty(bus.Name)) { return(Utilities.ErrorJson("Bus name cannot be empty")); } if (bus.Name.Length > 300) { return(Utilities.ErrorJson("Bus name is too long (limit 300 characters)")); } try { busRepo.CreateBus(bus.Name, bus.Route); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(new JsonResult(new { Error = "" })); }
void addNewItem_Click(object sender, EventArgs e) { switch (flag) { case "Buses": dgvBusStation.EndEdit(); Buses bus = (Buses)binSourceBusStation.Current; BusRepository rep = new BusRepository(); rep.Create(bus); Seats seat; SeatsRepository seatrep = new SeatsRepository(); for (int i = 0; i < bus.CountSeats; i++) { seat = new Seats(); seat.BusId = bus.BusId; seat.NumberSeat = i + 1; seatrep.Create(seat); } break; default: dgvBusStation.EndEdit(); T t = (T)binSourceBusStation.Current; repository.Create(t); break; } }
public ActionResult ViewDetails() { BusRepository busRepository = new BusRepository(); IEnumerable <BusEntity> bus = busRepository.Display(); ViewData["BusDetail"] = bus; return(View()); }
public IEnumerable <BusModel> Get() { BusRepository busRepository = new BusRepository(); return(busRepository.BusInGarage2().ToList() .Select(x => new BusModel { BusId = x.buszId })); }
public BusController(BusRepository busRepository, BusRouteRepository busRouteRepository, IMapper mapper, IWebHostEnvironment hostEnvironment) { this.busRepository = busRepository; this.busRouteRepository = busRouteRepository; this.mapper = mapper; this.hostEnvironment = hostEnvironment; }
/// <summary> /// Initializes a new instance of the <see cref="UnitOfWork"/> class. /// </summary> /// <param name="context">The context<see cref="ApplicationContext"/>.</param> public UnitOfWork(ApplicationContext context) { _context = context; Buses = new BusRepository(_context); Stops = new StopRepository(_context); Routes = new RouteRepository(_context); BusRoutes = new BusRouteRepository(_context); Bookings = new BookingRepository(_context); Users = new UserRepository(_context); }
public IEnumerable <AllBusModel> Get() { BusRepository busRepository = new BusRepository(); return(busRepository.GetBus().ToList() .Select(x => new AllBusModel { Bus = x.buszId })); }
public static List <BusListModel> GetAllBusesBySearch(string condition, string type) { var result = BusRepository.GetAllBusesBySearch(condition, type); foreach (var item in result) { item.busEncrpId = Encrypt.encryptMethod(item.bus_id.ToString()); item.busEncrpNumber = Encrypt.encryptMethod(item.busEncrpNumber); } return(result); }
public static List <BusListModel> GetAllDetails() { var result = BusRepository.GetAllBuses(); foreach (var item in result) { item.busEncrpId = Encrypt.encryptMethod(item.bus_id.ToString()); item.busEncrpNumber = Encrypt.encryptMethod(item.busEncrpNumber); } return(result); }
public static void ChangeStatusAndAddMechanic() { Buse bus = new Buse { Id = busId, MechanicId = Guid.Empty, Status = "Исправен" }; busRepository = new BusRepository(); busRepository.Update(bus); }
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 IEnumerable <VonalBuszSofor> Get() { BusRepository busRepository = new BusRepository(); return(busRepository.GetAllLineBusDriver().ToList() .Select(x => new VonalBuszSofor { vonalbuszsoforId = x.vonalbuszsoforId, soforId = x.soforId, vonalId = x.vonalId, buszId = x.buszId, datum = x.datum.Value })); }
public UnitOfWork(AppDbContext context) { _context = context; City = new CityRepository(_context); Region = new RegionRepository(_context); Bus = new BusRepository(_context); Fare = new FaresRepository(_context); AdminCity = new AdminCityRepository(_context); AdminRegion = new AdminRegionRepository(_context); Driver = new DriverRepository(_context); Status = new GenericRepository <Status, StatusDto>(_context); Route = new RouteRepository(_context); Schedule = new ScheduleRepository(_context); PaymentMethod = new PaymentMethodRepository(_context); }
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 TestDataSeeder(IServiceScope scope) { citizenUserRepository = scope.ServiceProvider.GetService <CitizenUserRepository>(); roleRepository = scope.ServiceProvider.GetService <RoleRepository>(); busRouteRepository = scope.ServiceProvider.GetService <BusRouteRepository>(); busRepository = scope.ServiceProvider.GetService <BusRepository>(); certificateRepository = scope.ServiceProvider.GetService <CertificateRepository>(); busWorkerRepository = scope.ServiceProvider.GetService <BusWorkerRepository>(); busRouteTimeRepository = scope.ServiceProvider.GetService <BusRouteTimeRepository>(); if (citizenUserRepository == null || roleRepository == null) { throw new Exception("Cannot get services from ServiceProvider."); } }
static void Main(string[] args) { var aFile = "Test1,Test2"; var netListImportService = new NetListImportService(); var nets = netListImportService.Read(aFile); var netRepository = new NetRepository(); netRepository.AddAll(nets); var buses = InferredBusFactory.GroupIntoBuses(nets); var busRepository = new BusRepository(); busRepository.AddAll(buses); }
public UnityOfWork() { _Context = new EnsambladoraDbContext(); Asientos = new AsientoRepository(_Context); Automoviles = new AutomovilRepository(_Context); Buses = new BusRepository(_Context); Carros = new CarroRepository(_Context); Cinturones = new CinturonRepository(_Context); Ensambladoras = new EnsambladoraRepository(_Context); Llantas = new LlantaRepository(_Context); Parabrisas = new ParabrisasRepository(_Context); Propietarios = new PropietarioRepository(_Context); Volantes = new VolanteRepository(_Context); }
public IEnumerable <LineStationModel> GetLines(int id) { BusRepository busRepository = new BusRepository(); return(busRepository.GetAllLineStation().Where(g => g.vonalId == id) .ToList().Select(x => new LineStationModel { Id = x.vonalMegalloiId, lineId = x.Vonal.vonalId, stationId = x.Megallok.megalloId, stationName = x.Megallok.megalloNev, lon = x.Megallok.lat.Value, lat = x.Megallok.lon.Value })); }
public IEnumerable <BusesOnTheRoadModel> Get() { BusRepository busRepository = new BusRepository(); return(busRepository.GetAllBusOnRoad().ToList() .Select(x => new BusesOnTheRoadModel { Id = x.felszallasId, Line = x.Vonal.vonalId, Bus = x.Busz.buszId, Date = x.datum.Value, lon = x.lat.Value, lat = x.lon.Value })); }
public UnitOfWork(RoleplayContext context) { _context = context; AccountRepository = new AccountRepository(_context); CharacterRepository = new CharacterRepository(_context); VehicleRepository = new VehicleRepository(_context); AtmRepository = new AtmRepository(_context); BusRepository = new BusRepository(_context); BuildingRepository = new BuildingRepository(_context); ItemRepository = new ItemRepository(_context); ShopRepository = new ShopRepository(_context); GroupRepository = new GroupRepository(_context); WarehouseRepository = new WarehouseRepository(_context); SmartphoneMessageRepository = new SmartphoneMessageRepository(_context); }
public IEnumerable <BusesOnTheRoadModel> GetLines(int id) { BusRepository busRepository = new BusRepository(); return(busRepository.GetAllBusOnRoad().Where(g => g.vonalId == id) .ToList().Select(s => new BusesOnTheRoadModel { Id = s.felszallasId, Line = s.Vonal.vonalId, Bus = s.Busz.buszId, Date = s.datum.Value, lon = s.lat.Value, lat = s.lon.Value })); }
public async Task <IActionResult> AssignBusDriver(BusModel model) { VolunteerRepository repo = new VolunteerRepository(configModel.ConnectionString); BusRepository busRepo = new BusRepository(configModel.ConnectionString); BusModel bus; VolunteerModel profile; var user = await userManager.GetUserAsync(User); /// Ensure that ONLY staff accounts have access to this API endpoint if (user == null || !await userManager.IsInRoleAsync(user, UserHelpers.UserRoles.Staff.ToString())) { return(Utilities.ErrorJson("Not authorized")); } // Validate the inputs bus = busRepo.GetBus(model.Id); if (bus == null) { return(Utilities.ErrorJson("Invalid bus id")); } profile = repo.GetVolunteer(model.DriverId); if (profile == null) { return(Utilities.ErrorJson("Invalid driver id")); } if (profile.Role != UserHelpers.UserRoles.BusDriver.ToString()) { return(Utilities.ErrorJson("That user is not a bus driver")); } // Update in the database try { busRepo.AssignDriver(model.Id, model.DriverId); } catch (Exception e) { return(Utilities.ErrorJson(e.Message)); } return(Utilities.NoErrorJson()); }
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 })); }