Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 public static Trip GetTrip(int tripId)
 {
     return(TripDal.GetTrip(tripId));
 }
Exemplo n.º 4
0
 public static void TruncateTrips()
 {
     TripDal.TruncateTrips();
 }
Exemplo n.º 5
0
 public static dynamic GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(GeoRectangle geoRectangle)
 {
     geoRectangle.Validate();
     return(TripDal.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(geoRectangle));
 }
Exemplo n.º 6
0
 public static int GetTotalTripsThroughGeoRectangle(GeoRectangle geoRectangle)
 {
     geoRectangle.Validate();
     return(TripDal.GetTotalTripsThroughGeoRectangle(geoRectangle));
 }
Exemplo n.º 7
0
 public static Trip GetTripWithMessages(int tripId)
 {
     return(TripDal.GetTripWithMessages(tripId));
 }