workouttest_app/lib/model/exercise_result.dart
2020-12-17 22:32:45 +01:00

45 lines
1.2 KiB
Dart

import 'package:aitrainer_app/model/result.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
class ExerciseResult {
int exerciseResultId;
int customerId;
int exerciseId;
int exercisePlanId;
String resultType;
double value;
DateTime dateFrom;
DateTime dateTo;
ResultExt resultExtension;
Map<String, dynamic> toJson() {
String formattedDateTo;
if (dateTo != null) {
formattedDateTo = DateFormat('yyyy-MM-dd HH:mm').format(dateTo);
}
return {
"customerId": customerId,
"exerciseId": exerciseId,
"exercisePlanId": exercisePlanId,
"resultType": resultType,
"value": value,
"dateFrom": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateFrom),
"dateTo": formattedDateTo,
};
}
ExerciseResult.fromJson(Map json) {
this.exerciseResultId = json['exerciseResultId'];
this.exerciseId = json['exerciseId'];
this.exercisePlanId = json['exercisePlanId'];
this.customerId = json['customerId'];
this.resultType = json['resultType'];
this.value = json["value"];
this.dateFrom = DateTime.parse(json['dateFrom']);
this.dateTo = DateTime.parse(json['dateTo']);
this.resultExtension = ResultExt(itemString: this.resultType);
}
}