public async Task <List <Driver> > ListDrivers() { var oDriverRepository = new DriverRepository(); IDataReader oDataReader = null; try { oDataReader = await oDriverRepository.List(); } catch (Exception) { throw; } var lstDrivers = new List <Driver>(); while (oDataReader.Read()) { var oDriver = new Driver(oDataReader); lstDrivers.Add(oDriver); } oDataReader.Close(); return(lstDrivers); }
public void CarExample_SetCamaroDriverName() { var repository = new CarRepository(); var camaro = repository.SingleByPrimaryKey("Camaro"); var dRepository = new DriverRepository(); dRepository.StartEdit(); camaro.CarDriver.DriverAge = 25; camaro.CarDriver.DriverName = "GEORGE"; dRepository.Update(camaro.CarDriver); Assert.AreEqual(25, camaro.CarDriver.DriverAge); Assert.AreEqual("GEORGE", camaro.CarDriver.DriverName); camaro.CarDriver.DriverAge = 19; camaro.CarDriver.DriverName = "George"; dRepository.Update(camaro.CarDriver); dRepository.StopEdit(false); Assert.AreEqual(19, camaro.CarDriver.DriverAge); Assert.AreEqual("George", camaro.CarDriver.DriverName); }
public ShiftAppService() { _shiftRepository = new EntityFramework.WorkShiftRepository(); _driverRepository = new EntityFramework.DriverRepository(); _breakRepository = new EntityFramework.BreakRepository(); _drivingShiftRepository = new EntityFramework.DrivingShiftRepository(); }
public void AddDriverTripDetailsForUnRegisteredDriver() { // arrange var driverName = "derian"; var unregisteredDriverName = "thanh"; string[] drivers = { $"Driver {driverName}" }; string[] tripDetails = { $"Trip {unregisteredDriverName} 15:05 15:16 38.0" }; var DriverObject = Fixture.Build <Driver>() .With(d => d.Name, driverName) .Create(); var TripObject = Fixture.Build <Trip>() .With(t => t.DriverName, driverName) .Create(); // add trip object to driver DriverObject.TripList.Add(TripObject); DriverRepository.Setup(x => x.RegisterNewDriver(It.IsAny <Driver>())).Returns(DriverObject); DriverRepository.Setup(x => x.AddDriverDetails(It.IsAny <Trip>())); var driverService = new DriverService(DriverRepository.Object, new Mock <ILogger <DriverService> >().Object); // act var driver = driverService.RegisterDrivers(drivers).FirstOrDefault(); Exception ex = Assert.Throws <ArgumentException>(() => driverService.AddDriverTripDetails(tripDetails)); // assert Assert.Equal($"Cannot add trip details for a non-existant user: {unregisteredDriverName}", ex.Message); }
public static async Task <IActionResult> ActivateDriver([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req) { req.IsValidToken(); try { await DriverRepository <Driver> .Initialize(); string requestBody = new StreamReader(req.Body).ReadToEnd(); dynamic dr = JsonConvert.DeserializeObject(requestBody); if (dr == null) { return((ActionResult) new OkObjectResult("Driver Cannot Be Null")); } var updDr = await DriverRepository <Driver> .UpdateItemAsync(dr.id, dr); if (updDr != null) { return((ActionResult) new OkObjectResult(updDr)); } return((ActionResult) new OkObjectResult(null)); } catch (Exception ex) { return((ActionResult) new OkObjectResult(ex)); } }
public static XPathNodeIterator GetDriver(int driverId) { var driverRepository = new DriverRepository(); var driver = driverRepository.GetById(driverId); return DriverToXml(driver); }
/// <summary> /// Adds a new driver to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddDriverToDatabase(object sender, EventArgs e) { string lDriverName = mDriverName.Text; DriverRepository driverRepository = new DriverRepository(); driverRepository.InsertNewDriver(lDriverName); int DriverId = driverRepository.GetLastDriverID(); if (DriverId != -1) { // Copy the default avater to the sysrem AvatarManager avatarManager = new AvatarManager(); if (!avatarManager.DestinationImageIsPresent()) { avatarManager.CopyImage(); } if (OnCreateDriver != null) { OnCreateDriver.Invoke(this, new CreateDriverEventArgs(mDriverName.Text, DriverId)); } } Dismiss(); }
public bool AddRateToUser(string username, float rate) { var driver = DriverRepository.GetDriverByUsername(username).Result; driver.Ratings.Add(rate); return(true); }
public ChampionshipController() { this.carRepository = new CarRepository(); this.driverRepository = new DriverRepository(); this.raceRepository = new RaceRepository(); this.carFactory = new CarFactory(); }
public IHttpActionResult Login(LoginDTO loginUser) { DriverRepository dr = new DriverRepository(); List <User> users = rep.ReadUsers(); List <Driver> drivers = dr.ReadDrivers(); User logUser = null; if (users != null && drivers != null) { foreach (User user in users) { if (user.Username == loginUser.Username && user.Password == loginUser.Password) { logUser = user; } } foreach (User user in drivers) { if (user.Username == loginUser.Username && user.Password == loginUser.Password) { logUser = user; } } if (logUser != null) { return(Ok(logUser)); } } return(NotFound()); }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req) { //Driver user = await req.Content.ReadAsAsync<Driver>(); //req.IsValidToken(); string requestBody = new StreamReader(req.Body).ReadToEnd(); Driver user = JsonConvert.DeserializeObject <Driver>(requestBody); await DriverRepository <Driver> .Initialize(); if (user == null) { return((ActionResult) new OkObjectResult("User cannot be null or empty")); } if (string.IsNullOrEmpty(user.Email)) { return((ActionResult) new OkObjectResult("An email address is needed for this request")); } try { var udb = DriverRepository <Driver> .GetItems($"Select * from DriverData u where u.Email = '{user.Email}'"); if (udb != null && udb.Count() > 0) { return((ActionResult) new OkObjectResult("Driver already exist, please login or activate account to continue")); } } catch (Exception ex) { return((ActionResult) new OkObjectResult(ex)); } if (string.IsNullOrEmpty(user.Password)) { return((ActionResult) new OkObjectResult("A Password is needed for this request")); } user.Password = user.Password.EncodeString(); user.LastModified = DateTime.Now; user.IsActivated = false; try { dynamic u = await DriverRepository <Driver> .CreateItemAsync(user); //Rider rider = u as Rider; return((ActionResult) new OkObjectResult("Your account has been created. Admin will contact via the number provided to complete the activation process.")); } catch (Exception ex) { return((ActionResult) new OkObjectResult("An error has occured")); } }
public TechInspectionWindow() { InitializeComponent(); DataContext = this; driverRep = new DriverRepository(); carRep = new CarRepository(); techInspectionRep = new TechInspectionRep(); }
public OrderController() { TaxiHeavenContext ctx = new TaxiHeavenContext(); _driverRepository = new DriverRepository(ctx); _workSessionRepository = new WorkSessionRepository(ctx); _orderRepository = new OrderRepository(ctx); }
public ActionResult Featured() { var repository = new DriverRepository(); var driver = repository.GetDriver(); var driverViewModel = repository.GetDriverViewModel(driver); return(View(driver)); }
public ReportWindow() { InitializeComponent(); reportRep = new ReportRepository(); driverRep = new DriverRepository(); carRep = new CarRepository(); DataContext = this; }
public void ViewDrivers(IMainController _mainController, IShowDriversView inForm) { DriverRepository _driverRepository = DriverRepository.GetInstance(); List <Driver> drivers = _driverRepository.GetAllActiveDrivers(); inForm.ShowModaless(_mainController, drivers); }
public void RefreshDrivers() { using (var db = DB.GetContext()) { this.Drivers.Clear(); this.Drivers.AddRange(DriverRepository.FindDrivers(db, this.Filter)); } }
public ExtendedRolesProvider() { _roleFeaturesRepository = new RoleFeaturesRepository(new DatabaseFactory()); _featuresRepository = new FeaturesRepository(new DatabaseFactory()); _basicRepository = new BasicRepository(new DatabaseFactory()); _employeeRepository = new EmployeeRepository(new DatabaseFactory()); _driverRepository = new DriverRepository(new DatabaseFactory()); }
public DashBoardController() { db = new CannDashDataContext(); customerRepository = new CustomerRepository(db); driverRepository = new DriverRepository(db); orderRepository = new OrderRepository(db); graphDataRepository = new GraphDataRepository(db); }
public UnitOfWork(RaceManagerDbContext context) { _context = context; Races = new RaceRepository(_context); Drivers = new DriverRepository(_context); Vehicles = new VehicleRepository(_context); Users = new UserRepository(_context); }
public UnitOfWork(TransportationAssetsContext context) { _context = context; Companies = new CompanyRepository(_context); Drivers = new DriverRepository(_context); Vehicles = new VehicleRepository(_context); FleetManagers = new FleetManagerRepository(_context); }
public void ViewStandings(IShowStandingsView inForm) { DriverRepository _driverRepository = DriverRepository.GetInstance(); List <Driver> sortedDrivers = Standings.GetStandings(_driverRepository.GetAllDrivers()); inForm.ShowModaless(sortedDrivers); }
public void Test_MaximumNumberOfDriversExceeded() { DriverRepository driverRepository = DriverRepository.GetInstance(); for (int i = 1; i < 22; ++i) { driverRepository.AddDriver(new Driver(i, "Nije", "Bitno")); } }
public void Test_AddingSameDriverReferenceTwice() { DriverRepository driverRepository = DriverRepository.GetInstance(); Driver driver = new Driver(5, "Sebastian", "Vettel"); driverRepository.AddDriver(driver); driverRepository.AddDriver(driver); }
public List <DriverModel> GetDrivers() { using (var db = DB.GetContext()) { DriverFilterModel filter = new DriverFilterModel(); filter.IncludeDisabled = false; return(DriverRepository.FindDrivers(db, filter)); } }
public HistoryViewModel(INavigationService navigationService) : base(navigationService) { Icon = "history.png"; Title = "History"; History = new ObservableCollection<RequestDTO>(); Carrepository = new CarsRepository(App.DbPath); DriverRepo = new DriverRepository(App.DbPath); Requestrepo = new RequestRepository(App.DbPath); }
public UnitOfWorkContainer(PruebaTecnicaDbContext context) { _context = context; VehicleRepository = new VehicleRepository(context); DriverRepository = new DriverRepository(context); InfringementRepository = new InfringementRepository(context); VehicleDriverRepository = new VehicleDriverRepository(context); InfringementVehicleDriverRepository = new InfringementVehicleDriverRepository(context); }
public void CalculateDriverScore() { DriverRepository repo = new DriverRepository(); Driver person = new Driver(2, 1, 8, 4); int actual = repo.CalculateDriverScore(person); int expected = 8; Assert.AreEqual(expected, actual); }
public void CalculateFinalPremium() { DriverRepository repo = new DriverRepository(); Driver person = new Driver(2, 1, 8, 4); int score = repo.CalculateDriverScore(person); decimal actual = repo.CalculateFinalPremium(score); decimal expected = 95.00m; Assert.AreEqual(expected, actual); }
public List <UtilityModel <uint> > GetDrivers() { using (var db = DB.GetContext()) { DriverFilterModel filter = new DriverFilterModel(); filter.IncludeDisabled = true; return(DriverRepository.FindDrivers(db, filter) .Select(d => new UtilityModel <uint>(d.DriverID, d.FullName)) .ToList()); } }
public Task <int> SaveDriverAsync(Driver driver) { if (driver.Id != 0) { return(DriverRepository.UpdateDriver(driver)); } else { return(DriverRepository.InsertDriver(driver)); } }
protected void UpdateProfileButton_Click(object sender, EventArgs e) { var driverRepo = new DriverRepository(); var profile = DriverProfile.GetDriverProfile(); var driver = driverRepo.GetById(profile.Driver.Id); driver.Name = GamerTagTextBox.Text; driver.AtomicName = AtomicUsernameTextBox.Text; if (!string.IsNullOrEmpty(AtomicUsernameTextBox.Text)) driver.AtomicUserId = int.Parse(AtomicUserIdTextBox.Text); driverRepo.Save(driver); var doc = GetDriverDocument(driver.Id); doc.ControllerMethod = ControllerTextBox.Text; doc.DislikedTracks = DislikedTracks.Text; doc.FavouriteTracks = FavouriteTracksTextBox.Text; doc.RacingView = RacingViewTextBox.Text; doc.About = AboutTextBox.Text; doc.PCSpec = PCSpecTextBox.Text; doc.Save(); Messages.SetSuccess("Updated Profile"); }