workouttest_app/lib/model/exercise_plan_template.dart
2021-03-28 12:45:14 +02:00

44 lines
1.4 KiB
Dart

import 'dart:ui';
import 'package:aitrainer_app/util/app_language.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'];
if (json['translations'].length > 0) {
this.nameTranslation = AppLanguage().appLocal == Locale('hu') ? json['translations'][0]['name'] : json['name'];
this.descriptionTranslation = AppLanguage().appLocal == Locale('hu') ? json['translations'][0]['description'] : json['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()
};
}
}