private TrackedRideDocument CreateTrackedRideForRide(Ride ride) { var tr = new TrackedRideDocument(); tr.Device = ride.Vehicle.DeviceId; tr.StartTime = ride.StartDateTime; tr.EndTime = ride.EndDateTime; tr.DriverId = ride.DriverId; AddGpsPoints(tr); AddObds(tr); return tr; }
private TrackedRideDocument GetOrCreateTrackedRide(Ride ride, IEnumerable<TrackedRideDocument> trackedRides) { var trackedRide = trackedRides.FirstOrDefault(tr => tr.DriverId == ride.DriverId && tr.StartTime <= ride.StartDateTime && tr.EndTime >= ride.EndDateTime && tr.Device == ride.Vehicle.DeviceId); return trackedRide ?? CreateTrackedRideForRide(ride); }