workouttest_app/lib/model/exercise_plan_template.dart
2021-03-09 15:49:15 +01:00

38 lines
1.3 KiB
Dart

class ExercisePlanTemplate {
int exercisePlanTemplateId;
String name;
String description;
String templateType;
String nameTranslation;
String descriptionTranslation;
List<int> exerciseTypes = List();
ExercisePlanTemplate.fromJson(Map json) {
this.exercisePlanTemplateId = json['exercisePlanId'];
this.name = json['name'];
this.description = json['description'];
this.templateType = json['templateType'];
this.nameTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['name'] : this.name;
this.descriptionTranslation =
json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['description'] : this.description;
if (json['details'] != null && (json['details']).length > 0) {
List details = json['details'];
details.forEach((element) {
exerciseTypes.add(element['exerciseTypeId']);
});
}
}
Map<String, dynamic> toJson() {
return {
"exercisePlanTemplateId": exercisePlanTemplateId,
"name": name,
"description": "description",
"templateType": templateType,
"nameTranslation": nameTranslation,
"descriptionTranslation": descriptionTranslation,
"exerciseTypes": exerciseTypes.toString()
};
}
}