private static void ValidateTripMessage(TripMessage tripMessage) { tripMessage.Validate(); var trip = TripDal.GetTrip(tripMessage.TripId); if (TripEvent.Begin == tripMessage.Event) { if (trip != null) { throw new TripAlreadyExistsException( "Trip with ID {0} already exists, therefore a begin message cannot be saved.", tripMessage.TripId); } } else { if (null == trip) { throw new TripDoesNotExistException( "Trip with ID {0} does not exist, therefore a non begin message cannot be saved.", tripMessage.TripId); } if (trip.LastMessageEpoch >= tripMessage.Epoch) { throw new TripAlreadyHasMessageAfterEpochException( "Trip with ID {0} already has an update after the messages epoch, therefore a non begin message cannot be saved.", tripMessage.TripId); } if (trip.EndEpoch.HasValue) { throw new TripAlreadyEndedException( "Trip with ID {0} has already ended, therefore a message can not be saved.", tripMessage.TripId); } } }
public static int GetTotalTripsOccuringAtTime(long epoch) { if (epoch <= 0) { throw new ArgumentException("Epoch must be an integer greater than 0.", "epoch"); } return(TripDal.GetTotalTripsOccuringAtTime(epoch)); }
public static Trip GetTrip(int tripId) { return(TripDal.GetTrip(tripId)); }
public static void TruncateTrips() { TripDal.TruncateTrips(); }
public static dynamic GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(GeoRectangle geoRectangle) { geoRectangle.Validate(); return(TripDal.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(geoRectangle)); }
public static int GetTotalTripsThroughGeoRectangle(GeoRectangle geoRectangle) { geoRectangle.Validate(); return(TripDal.GetTotalTripsThroughGeoRectangle(geoRectangle)); }
public static Trip GetTripWithMessages(int tripId) { return(TripDal.GetTripWithMessages(tripId)); }