Daily commit
This commit is contained in:
39
lib/repository/tour_repository.dart
Normal file
39
lib/repository/tour_repository.dart
Normal file
@ -0,0 +1,39 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user