40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
import 'package:app_gaslieferung/model/supplier.dart';
|
|
import 'package:app_gaslieferung/model/tour.dart';
|
|
import 'package:app_gaslieferung/service/tour_service.dart';
|
|
|
|
import '../model/car.dart';
|
|
|
|
class TourRepository {
|
|
TourService service;
|
|
|
|
TourRepository({required this.service});
|
|
|
|
/// Lists the possible tours of cars existing for a supplier.
|
|
Future<SupplierTourMetadata> getSupplierTourMetadata(String sessionId) async {
|
|
final dto = await service.getCars(sessionId);
|
|
|
|
await Future.delayed(Duration(seconds: 1));
|
|
|
|
return SupplierTourMetadata(
|
|
date: dto.date,
|
|
tours: dto.deliveries
|
|
.map(
|
|
(delivery) => TourMetadata(
|
|
car: Car(id: delivery.car.id, carName: delivery.car.carName, driverName: delivery.car.driverName),
|
|
amountDeliveries: delivery.amountDeliveries,
|
|
),
|
|
)
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
/// Lists the possible tours of cars existing for a supplier.
|
|
Future<Tour> getTour(String sessionId, String carId) async {
|
|
final tour = await service.getTour(sessionId, carId);
|
|
|
|
await Future.delayed(Duration(seconds: 1));
|
|
|
|
return tour;
|
|
}
|
|
}
|