private void ValidateRideLeg(RideLeg rideLeg) { if (rideLeg.StartTime >= new TimeSpan(24, 0, 0)) { throw new ArgumentOutOfRangeException("StartTime must be less than 24:00:00"); } }
public async Task DeleteRideLegAsync(RideLeg rideLeg) { // TODO: Do we need to delete the Locations too? _uow.RideLegs.Delete(rideLeg); await _uow.SaveChangesAsync(); }
public async Task <RideLeg> EditRideLegAsync(RideLeg rideLeg) { // Todo: update time and distance if location has changed ValidateRideLeg(rideLeg); _uow.RideLegs.Edit(rideLeg); await _uow.SaveChangesAsync(); return(rideLeg); }
private void SetUpTestData() { DateTime startDate = new DateTime(2000, 1, 1); DateTime endDate = new DateTime(2029, 1, 1); _testOwner = new User() { Name = "Me", Email = "*****@*****.**", IsDriver = true, IsRider = false, IdentityUserId = Guid.NewGuid() }; _testRider = new User() { Name = "Somebody", Email = "*****@*****.**", IsDriver = false, IsRider = true, IdentityUserId = Guid.NewGuid() }; _testLocation1 = new Location() { Address = new Address() { Line1 = "10236 180th Ave", City = "LeRoy", State = "MI", PostalCode = "49655", Country = "US" }, LatLng = new LatLng() { Lat = 43.96299F, Lng = -85.44361F }, Name = "Home", Owner = _testOwner }; _testLocation2 = new Location() { Address = new Address() { Line1 = "415 N Mitchell", City = "Cadillac", State = "MI", PostalCode = "49601", Country = "US" }, LatLng = new LatLng() { Lat = 44.253227F, Lng = -85.40183F }, Name = "Work", Owner = _testOwner }; _testLocation3 = new Location() { Address = new Address() { Line1 = "21400 Perry Ave", City = "Big Rapids", State = "MI", PostalCode = "496307", Country = "US" }, LatLng = new LatLng() { Lat = 43.687443F, Lng = -85.51758F }, Name = "WalMart Big Rapids" }; _testLocation4 = new Location() { Address = new Address() { Line1 = "130 Fulton St W", City = "Grand Rapids", State = "MI", PostalCode = "49503", Country = "US" }, LatLng = new LatLng() { Lat = 42.96322F, Lng = -85.67093F }, Name = "Van Andel Arena" }; _testLocation5 = new Location() { Address = new Address() { Line1 = "8917 E 34 Rd", City = "Cadillac", State = "MI", PostalCode = "49601", Country = "US" }, LatLng = new LatLng() { Lat = 44.281467F, Lng = -85.397835F }, Name = "WalMart Cadillac" }; _testRide1 = new Ride() { Creator = _testOwner, Driver = _testOwner, StartDate = startDate, EndDate = endDate, AvailableSeats = 3, IsSeekingRiders = true, IsSeekingDriver = false, Repeating = (byte)WeekDay.WeekDays }; _testRide2 = new Ride() { Creator = _testOwner, Driver = _testOwner, StartDate = startDate, EndDate = endDate, AvailableSeats = 3, IsSeekingRiders = true, IsSeekingDriver = false, Repeating = (byte)WeekDay.WeekDays }; _testRide3 = new Ride() { Creator = _testRider, IsSeekingRiders = false, IsSeekingDriver = true, Repeating = (byte)WeekDay.WeekDays }; _testRideLeg1 = new RideLeg() { Ride = _testRide1, Origin = _testLocation1, Destination = _testLocation2, StartTime = new TimeSpan(8, 0, 0), TravelTime = new TimeSpan(0, 25, 0), Distance = 20F }; _testRideLeg2 = new RideLeg() { Ride = _testRide1, Origin = _testLocation2, Destination = _testLocation1, StartTime = new TimeSpan(17, 0, 0), TravelTime = new TimeSpan(0, 25, 0), Distance = 20F }; _testRideLeg3 = new RideLeg() { Ride = _testRide2, Origin = _testLocation1, Destination = _testLocation3, StartTime = new TimeSpan(8, 0, 0), TravelTime = new TimeSpan(0, 25, 0) }; _testRideLeg4 = new RideLeg() { Ride = _testRide2, Origin = _testLocation3, Destination = _testLocation4, StartTime = new TimeSpan(12, 0, 0), TravelTime = new TimeSpan(0, 25, 0) }; _testRideLeg5 = new RideLeg() { Ride = _testRide2, Origin = _testLocation4, Destination = _testLocation1, StartTime = new TimeSpan(17, 0, 0), TravelTime = new TimeSpan(0, 25, 0) }; _testRideLeg6 = new RideLeg() { Ride = _testRide3, Origin = _testLocation1, Destination = _testLocation5, StartTime = new TimeSpan(8, 0, 0), TravelTime = new TimeSpan(0, 25, 0), Distance = 22F }; _testRideLeg7 = new RideLeg() { Ride = _testRide3, Origin = _testLocation5, Destination = _testLocation1, StartTime = new TimeSpan(17, 0, 0), TravelTime = new TimeSpan(0, 25, 0), Distance = 22F }; _testRideCost = new RideCost() { BaseCost = 2.00M, CostPerMile = 0.20M, PickupCostPerHour = 20M, PickupCostPerMile = .25M, PickupDistanceMileLimit = 20, PickupTimeLimitMinutes = 30 }; }