/// <summary>
        /// Adds an entity.
        /// </summary>
        /// <param name="stopTime"></param>
        public void Add(StopTime stopTime)
        {
            string sql = "INSERT INTO stop_time VALUES (:feed_id, :trip_id, :arrival_time, :departure_time, :stop_id, :stop_sequence, :stop_headsign, :pickup_type, :drop_off_type, :shape_dist_traveled);";
            using (var command = _connection.CreateCommand())
            {
                command.CommandText = sql;
                command.Parameters.Add(new SQLiteParameter(@"feed_id", DbType.Int64));
                command.Parameters.Add(new SQLiteParameter(@"trip_id", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"arrival_time", DbType.Int64));
                command.Parameters.Add(new SQLiteParameter(@"departure_time", DbType.Int64));
                command.Parameters.Add(new SQLiteParameter(@"stop_id", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"stop_sequence", DbType.Int64));
                command.Parameters.Add(new SQLiteParameter(@"stop_headsign", DbType.String));
                command.Parameters.Add(new SQLiteParameter(@"pickup_type", DbType.Int64));
                command.Parameters.Add(new SQLiteParameter(@"drop_off_type", DbType.Int64));
                command.Parameters.Add(new SQLiteParameter(@"shape_dist_traveled", DbType.String));

                command.Parameters[0].Value = _id;
                command.Parameters[1].Value = stopTime.TripId;
                command.Parameters[2].Value = stopTime.ArrivalTime.TotalSeconds;
                command.Parameters[3].Value = stopTime.DepartureTime.TotalSeconds;
                command.Parameters[4].Value = stopTime.StopId;
                command.Parameters[5].Value = stopTime.StopSequence;
                command.Parameters[6].Value = stopTime.StopHeadsign;
                command.Parameters[7].Value = stopTime.PickupType.HasValue ? (int?)stopTime.PickupType.Value : null;
                command.Parameters[8].Value = stopTime.DropOffType.HasValue ? (int?)stopTime.DropOffType.Value : null;
                command.Parameters[9].Value = stopTime.ShapeDistTravelled;

                command.ExecuteNonQuery();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Adds or replaces an entity in the given collection.
 /// </summary>
 public static void AddOrReplace(this IStopTimeCollection collection, Entities.StopTime entity)
 {
     if (!collection.Contains(entity))
     {
         collection.Add(entity);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Returns a new StopTime object created from a previous stop time object
 /// </summary>
 public static StopTime From(StopTime other)
 {
     return(new StopTime()
     {
         ArrivalTime = other.ArrivalTime,
         DepartureTime = other.DepartureTime,
         DropOffType = other.DropOffType,
         PickupType = other.PickupType,
         ShapeDistTravelled = other.ShapeDistTravelled,
         StopHeadsign = other.StopHeadsign,
         StopId = other.StopId,
         StopSequence = other.StopSequence,
         Tag = other.Tag,
         TripId = other.TripId,
         PassengerBoarding = other.PassengerBoarding,
         PassengerAlighting = other.PassengerAlighting,
         ThroughPassengers = other.ThroughPassengers,
         TotalPassengers = other.TotalPassengers
     });
 }