69 lines
2.0 KiB
Dart
69 lines
2.0 KiB
Dart
import 'package:intl/intl.dart';
|
|
|
|
class Exercise {
|
|
int? exerciseId;
|
|
int? exerciseTypeId;
|
|
int? customerId;
|
|
double? quantity;
|
|
String? unit;
|
|
double? unitQuantity;
|
|
DateTime? dateAdd;
|
|
int? exercisePlanDetailId;
|
|
int? trainingPlanDetailsId;
|
|
|
|
String? datePart;
|
|
double? calculated;
|
|
String? summary;
|
|
|
|
Exercise({exerciseTypeId, customerId, quantity, dateAdd});
|
|
|
|
Exercise.fromJson(Map json) {
|
|
exerciseId = json['exerciseId'];
|
|
exerciseTypeId = json['exerciseTypeId'];
|
|
customerId = json['customerId'];
|
|
quantity = json['quantity'];
|
|
unit = json['unit'];
|
|
unitQuantity = json['unitQuantity'];
|
|
dateAdd = DateTime.parse(json['dateAdd']);
|
|
datePart = DateFormat('yyyy-MM-dd').format(dateAdd!);
|
|
calculated = quantity;
|
|
exercisePlanDetailId = json['exercisePlanDetailId'] == "null" ? null : json['exercisePlanDetailId'];
|
|
trainingPlanDetailsId = json['trainingPlanDetailsId'] == "null" ? null : json['trainingPlanDetailsId'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"exerciseTypeId": exerciseTypeId,
|
|
"customerId": customerId,
|
|
"quantity": quantity,
|
|
"unit": unit,
|
|
"unitQuantity": unitQuantity,
|
|
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(dateAdd!),
|
|
"exercisePlanDetailId": exercisePlanDetailId,
|
|
"trainingPlanDetailsId": trainingPlanDetailsId,
|
|
};
|
|
|
|
Map<String, dynamic> toJsonDatePart() => {
|
|
"exerciseTypeId": exerciseTypeId,
|
|
"customerId": customerId,
|
|
"quantity": quantity,
|
|
'calculated': calculated,
|
|
"unit": unit,
|
|
"unitQuantity": unitQuantity,
|
|
"datePart": datePart,
|
|
};
|
|
|
|
Exercise copy() {
|
|
Exercise newExercise =
|
|
Exercise(exerciseTypeId: exerciseTypeId, customerId: customerId, quantity: quantity, dateAdd: dateAdd);
|
|
newExercise.unit = unit;
|
|
newExercise.unitQuantity = unitQuantity;
|
|
newExercise.exercisePlanDetailId = exercisePlanDetailId;
|
|
return newExercise;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return toJson().toString();
|
|
}
|
|
}
|