Skip to content
Snippets Groups Projects
Commit 675a0dfb authored by Andri Joos's avatar Andri Joos :blush:
Browse files

add start & end time to Route

parent 17af656c
No related merge requests found
......@@ -5,15 +5,21 @@ class Route implements DbModel, ResponseModel {
static const String userIdDbFieldName = "userId";
static const String teamIdDbFieldName = "teamId";
static const String pointsDbFieldName = "points";
static const String startTimeDbFieldName = "startTime";
static const String endTimeDbFieldName = "endTime";
static const String userIdRequestResponseFieldName = "userId";
static const String teamIdRequestResponseFieldName = "teamId";
static const String pointsRequestResponseFieldName = "points";
static const String startTimeRequestResponseFieldName = "startTime";
static const String endTimeRequestResponseFieldName = "endTime";
final String? _id;
final List<Point> _points;
final String _userId;
final String? _teamId;
final DateTime startTime;
final DateTime endTime;
@override
String? get id => _id;
......@@ -26,7 +32,7 @@ class Route implements DbModel, ResponseModel {
String? get teamId => _teamId;
Route({String? id, required List<Point> points, required String userId, String? teamId}) :
Route({String? id, required List<Point> points, required String userId, String? teamId, required this.startTime, required this.endTime}) :
_id = id,
_points = points,
_userId = userId,
......@@ -39,6 +45,8 @@ class Route implements DbModel, ResponseModel {
pointsDbFieldName: pointIds,
userIdDbFieldName : userId,
teamIdDbFieldName : teamId,
startTimeDbFieldName: startTime.toIso8601String(),
endTimeDbFieldName: endTime.toIso8601String(),
};
}
......@@ -58,6 +66,8 @@ class Route implements DbModel, ResponseModel {
points: getRequiredMapItem<Iterable>(pointsRequestResponseFieldName, map).map((e) => Point.fromRequest(e)).toList(growable: false),
userId: userId,
teamId: getOptionalMapItem(teamIdRequestResponseFieldName, map),
startTime: DateTime.parse(getRequiredMapItem(startTimeRequestResponseFieldName, map)),
endTime: DateTime.parse(getRequiredMapItem(endTimeRequestResponseFieldName, map)),
);
}
......@@ -67,6 +77,8 @@ class Route implements DbModel, ResponseModel {
points: getRequiredMapItem<Iterable>(pointsDbFieldName, map).map((e) => Point.fromDbData(e)).toList(growable: false),
userId: getRequiredMapItem(userIdDbFieldName, map),
teamId: getOptionalMapItem(teamIdDbFieldName, map),
startTime: DateTime.parse(getRequiredMapItem(startTimeDbFieldName, map)),
endTime: DateTime.parse(getRequiredMapItem(endTimeDbFieldName, map)),
);
}
}
......@@ -34,6 +34,8 @@ class RouteDatabase extends BaseDatabase<Route, Route> {
points: points,
userId: request.item.userId,
teamId: request.item.teamId,
startTime: request.item.startTime,
endTime: request.item.endTime,
),
requestingUser: request.requestingUser,
);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment