diff --git a/lib/transport_helper.dart b/lib/transport_helper.dart index b4050eb..3a0fa4a 100644 --- a/lib/transport_helper.dart +++ b/lib/transport_helper.dart @@ -739,7 +739,6 @@ class Line { } } -// TODO: add fromJson class Departure { static const String tableName = "departure"; @@ -772,6 +771,18 @@ class Departure { departureTime: map["departuretime"] as DateTime, ); } + factory Departure.fromJson(Map json) { + Vehicle vehicle = Vehicle.fromJson(json["Product"]); + vehicle.dbInsert(); + Station station = Station.fromJson(json["stop"]); + station.dbInsert(); + return Departure( + vehicleId: vehicle.id, + stationId: station.id, + departureTime: json["time"], + ); + } + static void initDepartureTable() async { Database database = DbHelper.db; String vehicle = Vehicle.tableName;