private Order CreateTestOrderWithSoloRideInDatabase(RideStatus rideStatus = RideStatus.WaitingForAccept, OrderStatus orderStatus = OrderStatus.WaitingForAccept, int minutes = 0) { using (var context = _factory.CreateContext()) { Customer customer = new Customer() { Name = "Name" }; context.Customers.Add(customer); SoloRide soloRide = new SoloRide() { CustomerId = customer.Id, DepartureTime = DateTime.Now, ConfirmationDeadline = DateTime.Now.AddMinutes(-minutes), PassengerCount = 0, CreatedOn = DateTime.Now, Price = 100, Status = rideStatus, EndDestination = new Address("City", 8200, "Street", 21), StartDestination = new Address("City", 8200, "Street", 21) }; context.SoloRides.Add(soloRide); Order order = new Order() { Status = orderStatus, Price = 100, Rides = new List <Ride>() }; order.Rides.Add(soloRide); context.Orders.Add(order); context.SaveChanges(); return(order); } }
public async Task FindExpiredUnmatchedRides_SearchRides_FindExpectedAmoutn(RideStatus status, int expiredMinutse, int count) { var customer = new Customer(); var soloRide = new SoloRide() { CustomerId = customer.Id, DepartureTime = DateTime.Now, ConfirmationDeadline = DateTime.Now.AddMinutes(-expiredMinutse), PassengerCount = 0, CreatedOn = DateTime.Now, Price = 100, Status = status, EndDestination = new Address("City", 8200, "Street", 21), StartDestination = new Address("City", 8200, "Street", 21) }; using (var context = _factory.CreateContext()) { context.Add(customer); context.Add(soloRide); context.SaveChanges(); } var rides = await _uut.RideRepository.FindExpiredUnmatchedRides(); Assert.That(rides.Count, Is.EqualTo(count)); }
public DriverRideDetailsQueryDto(IReadOnlyCollection <AddressDto> stops, MoneyDto income, CustomerDetailsDto customerDetails, RideStatus status) : base(income, customerDetails, status) { Stops = stops; }
protected DriverRideDetailsBaseDto(MoneyDto income, CustomerDetailsDto customerDetails, RideStatus status) { Income = income; CustomerDetails = customerDetails; Status = status; }
public Ride(Location source, ApplicationUser disp, RideVehicleType vehicle, ApplicationUser driver) { OrderDateTime = DateTime.Now; Source = source; VehicleType = vehicle; Dispatcher = disp; Driver = driver; Status = RideStatus.Formed; }
public CustomerRideDetailsQueryDto( IReadOnlyCollection <RouteDto> routes, RideStatus status, MoneyDto price, DateTime?finishedDate, DriverDetailsDto driverDetails) : base(status, price) { Routes = routes; FinishedDate = finishedDate; DriverDetails = driverDetails; }
public Ride(RideStatus status, Money income, int customerId, CustomerDetails customerDetails, params DestinationPoint[] stops) { Status = status; Income = income; CustomerId = customerId; CustomerDetails = customerDetails; Stops = stops; }
public Ride(DateTime datumporudzbine, Location lokacija, string musterija, Location odrediste, string vozac, double iznos, Comment komentar, RideStatus statusVoznje, string dispatcher, CARTYPE tipvozila) { DatumIVremePorudzbine = datumporudzbine; LokacijaPolazna = lokacija; Musterija = musterija; Odrediste = odrediste; Vozac = vozac; Iznos = iznos; Komentar = komentar; StatusVoznje = statusVoznje; Dispatcher = dispatcher; TipVozila = tipvozila; }
public Ride(RideStatus status, Coordinate coordinates, String name, int minimumAge, double minimumLength, TimeSpan duration, int maxPersons) : base(Guid.NewGuid(), LocationType.RIDE) { Status = status; Name = name; MinimumAge = minimumAge; MinimumLength = minimumLength; Duration = duration; MaxPersons = maxPersons; Coordinates = coordinates; // todo: Let's change this later to a flexible setup //setEmployeeSkillRequirement(WorkplaceSkill.Control, 2); //setEmployeeSkillRequirement(WorkplaceSkill.Host, 3); }
private List <RideStatus> fetchRidetatus(SqlCommand cmd) { SqlConnection con = cmd.Connection; List <RideStatus> rlist = null; con.Open(); using (con) { SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { rlist = new List <RideStatus>(); while (dr.Read()) { RideStatus r = new RideStatus(); r.Id = Convert.ToInt32(dr["Id"]); r.Status = Convert.ToString(dr["Status"]); rlist.Add(r); } rlist.TrimExcess(); } } return(rlist); }
public override async Task <RideDTO> CreateAsync(RideDTO dtoObject) { using (var trans = this.UnitOfWork.DBContext.Database.BeginTransaction()) { Customer customer = await this.UnitOfWork.CustomerRepository.GetByUserId(this.requestInfo.UserId); if (customer == null) { customer = await this.UnitOfWork.CustomerRepository.Create(new Customer() { UserId = this.requestInfo.UserId }); } IEnumerable <Ride> rideEntities = await this.Repository.GetByCustomerId(customer.Id); if (rideEntities.Where(x => x.IsActive).Count() == 0) { LocationLagLon sourceEntity = null; LocationLagLon destinationEntity = null; Distance rideDistance = null; if (dtoObject.Source != null) { sourceEntity = await this.UnitOfWork.LocationLagLonRepository.Create(dtoObject.Source.ConvertToEntity()); } if (dtoObject.Destination != null) { destinationEntity = await this.UnitOfWork.LocationLagLonRepository.Create(dtoObject.Destination.ConvertToEntity()); } if (dtoObject.Source != null && dtoObject.Destination != null) { DistanceUnit distanceUnit = await this.UnitOfWork.DistanceUnitRepository.GetByCode(Core.Constant.DistanceUnit.Kilometer); if (distanceUnit != null) { rideDistance = await this.UnitOfWork.DistanceRepository.Create(new Distance() { UnitId = distanceUnit.Id, TotalDistance = (await CalculateDistance(dtoObject.Destination.Latitude, dtoObject.Destination.Longitude, dtoObject.Source.Latitude, dtoObject.Source.Longitude)) }); } } await this.UnitOfWork.SaveAsync(); RideStatus rideStatus = await this.UnitOfWork.RideStatusRepository.GetByCode(Core.Constant.RideStatus.Waiting); dtoObject.SourceId = sourceEntity.Id; dtoObject.DestinationId = destinationEntity.Id; dtoObject.RideDistanceId = rideDistance.Id; dtoObject.CustomerId = customer.Id; dtoObject.IsActive = true; if (rideStatus != null) { dtoObject.RideStatusId = rideStatus.Id; } dtoObject = await base.CreateAsync(dtoObject); trans.Commit(); return(dtoObject); } else { return(await this.CustomerHeartBeatAsync(dtoObject)); } } }
public IEnumerable <Ride> Get([FromUri] GetRidesFilterDTO filter) { if (!UserPrincipal.IsLoged) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } IEnumerable <Ride> rides = null; if (UserPrincipal.IsDispatcher) { if (filter.OnlyAssigned) { rides = (uow.UserRepository.GetByID(UserPrincipal.CurrentUser.Id) as Dispatcher).Rides; } else { rides = uow.RideRepository.Get(); } } else if (UserPrincipal.IsDriver) { if (filter.OnlyAssigned) { rides = (uow.UserRepository.GetByID(UserPrincipal.CurrentUser.Id) as Driver).Rides; } else { rides = uow.RideRepository.Get().Where(r => r.Status == RideStatus.Created); } } else if (UserPrincipal.IsCustomer) { rides = (uow.UserRepository.GetByID(UserPrincipal.CurrentUser.Id) as Customer).Rides; } if (filter.StatusFilter != null) { RideStatus statusFilter = (RideStatus)filter.StatusFilter; rides = rides.Where(r => r.Status == statusFilter); } DateTime fromDate = filter.FromOrderDate == null ? DateTime.MinValue : (DateTime)filter.FromOrderDate; DateTime toDate = filter.ToOrderDate == null ? DateTime.MaxValue : (DateTime)filter.ToOrderDate; int fromRate = filter.FromRate == null ? int.MinValue : (int)filter.FromRate; int toRate = filter.ToRate == null ? int.MaxValue : (int)filter.ToRate; int fromPrice = filter.FromPrice == null ? int.MinValue : (int)filter.FromPrice; int toPrice = filter.ToPrice == null ? int.MaxValue : (int)filter.ToPrice; rides = rides.Where(r => (r.Date >= fromDate && r.Date <= toDate) && (r.Amount >= fromPrice && r.Amount <= toPrice)); if (filter.FromRate != null || filter.ToRate != null) { rides = rides.Where(r => (r.Comment != null && r.Comment.Rating >= fromRate && r.Comment.Rating <= toRate)); } GetRidesFilterDTO drf = filter; if (UserPrincipal.IsDispatcher && drf != null) { if (drf.CustomerName != null) { rides = rides.Where(r => r.Customer != null && r.Customer.FirstName != null && r.Customer.FirstName.Equals(drf.CustomerName)); } if (drf.CustomerLastName != null) { rides = rides.Where(r => r.Customer != null && r.Customer.LastName != null && r.Customer.LastName.Equals(drf.CustomerLastName)); } if (drf.DriverName != null) { rides = rides.Where(r => r.Driver != null && r.Driver.FirstName != null && r.Driver.FirstName.Equals(drf.DriverName)); } if (drf.DriverLastName != null) { rides = rides.Where(r => r.Driver != null && r.Driver.LastName != null && r.Driver.LastName.Equals(drf.DriverLastName)); } } if (filter.SortFilter == RideFilterSort.ByDate) { rides = rides.OrderByDescending(r => r.Date.Ticks); } else if (filter.SortFilter == RideFilterSort.ByRate) { rides = rides.OrderByDescending(r => r.Comment == null ? int.MaxValue : r.Comment.Rating); } else if (filter.SortFilter == RideFilterSort.ByDistance && UserPrincipal.IsDriver) { Driver driver = uow.UserRepository.GetByID(UserPrincipal.CurrentUser.Id) as Driver; if (driver.Location != null) { GeoCoordinate cord = new GeoCoordinate(driver.Location.X, driver.Location.Y); rides = rides.OrderBy(r => new GeoCoordinate(r.StartLocation.X, r.StartLocation.Y).GetDistanceTo(cord)); } } return(rides); }
public IEnumerable <Ride> GetRidesForDriver(RideStatus rideStatus, int vehicleTypeId) { return(Context.Rides.Include("Payment").Where(vt => vt.RideStatus == rideStatus && vt.VehicleTypeId == vehicleTypeId).ToList()); }
public InvalidRideStatusException(RideStatus status, Guid rideId) : base($"Invalid ride status: '{status}' for ride with id: {rideId}") { }
public async Task FindOrdersWithExpiredRides_OrdersRideHasWaitingForAccept_OrderIsReturned(RideStatus rideStatus, OrderStatus orderStatus, int minutes, int count) { CreateTestOrderWithSoloRideInDatabase(rideStatus, orderStatus, minutes); var orders = await _uut.OrderRepository.FindOrdersWithExpiredRides(); Assert.That(orders.Count, Is.EqualTo(count)); }
public RideStatusEventArgs(RideStatus rideStatus) { CurrentRidestatus = rideStatus; }
public void Update(FailedRideForm f) { Comment = new Comment(f, Driver, this); Status = RideStatus.Failed; }
public void Update(SuccesfulRideForm f) { Destination = new Location(f); Price = f.Price; Status = RideStatus.Successful; }
protected CustomerRideDetailsDtoBase(RideStatus status, MoneyDto price) { Price = price; Status = status; }