Umbau auf directus API Rest Service
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
|
||||
|
||||
class TankGuruDirectusModel {
|
||||
int? iD;
|
||||
String? userIdentId;
|
||||
String? tankDate;
|
||||
String? odometer;
|
||||
String? liter;
|
||||
String? pricePerLiter;
|
||||
String? standort;
|
||||
String? createdAt;
|
||||
String? szPriceTotal;
|
||||
|
||||
TankGuruDirectusModel(
|
||||
{this.iD,
|
||||
this.userIdentId,
|
||||
this.tankDate,
|
||||
this.odometer,
|
||||
this.liter,
|
||||
this.pricePerLiter,
|
||||
this.standort,
|
||||
this.createdAt,
|
||||
this.szPriceTotal});
|
||||
|
||||
TankGuruDirectusModel.fromJson(Map<String, dynamic> json) {
|
||||
iD = json['ID'];
|
||||
userIdentId = json['UserIdentId'];
|
||||
tankDate = json['TankDate'];
|
||||
odometer = json['Odometer'];
|
||||
liter = json['Liter'];
|
||||
pricePerLiter = json['PricePerLiter'];
|
||||
standort = json['Standort'];
|
||||
createdAt = json['CreatedAt'];
|
||||
// Berechnung des Gesamtpreises
|
||||
if (liter != null && pricePerLiter != null) {
|
||||
double literValue = double.tryParse(liter!) ?? 0.0;
|
||||
double pricePerLiterValue = double.tryParse(pricePerLiter!) ?? 0.0;
|
||||
szPriceTotal = (literValue * pricePerLiterValue).toStringAsFixed(3);
|
||||
} else {
|
||||
szPriceTotal = '0.00';
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['ID'] = iD;
|
||||
data['UserIdentId'] = userIdentId;
|
||||
data['TankDate'] = tankDate;
|
||||
data['Odometer'] = odometer;
|
||||
data['Liter'] = liter;
|
||||
data['PricePerLiter'] = pricePerLiter;
|
||||
data['Standort'] = standort;
|
||||
data['CreatedAt'] = createdAt;
|
||||
data['SzPriceTotal'] = szPriceTotal;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user