47 lines
1.2 KiB
Dart
47 lines
1.2 KiB
Dart
import 'package:workouttest_util/model/result.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class ExerciseResult {
|
|
late int? exerciseResultId;
|
|
late int customerId;
|
|
late int exerciseId;
|
|
late int exercisePlanId;
|
|
late String resultType;
|
|
late double value;
|
|
late DateTime dateFrom;
|
|
late DateTime? dateTo;
|
|
|
|
ResultExt? resultExtension;
|
|
|
|
ExerciseResult();
|
|
|
|
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(dateFrom),
|
|
"dateTo": formattedDateTo,
|
|
};
|
|
}
|
|
|
|
ExerciseResult.fromJson(Map json) {
|
|
exerciseResultId = json['exerciseResultId'];
|
|
exerciseId = json['exerciseId'];
|
|
exercisePlanId = json['exercisePlanId'];
|
|
customerId = json['customerId'];
|
|
resultType = json['resultType'];
|
|
value = json["value"];
|
|
dateFrom = DateTime.parse(json['dateFrom']);
|
|
dateTo = DateTime.parse(json['dateTo']);
|
|
resultExtension = ResultExt(itemString: resultType);
|
|
}
|
|
}
|