workouttest_app/lib/model/faq.dart
2021-09-05 07:47:15 +02:00

38 lines
1.1 KiB
Dart

import 'dart:collection';
class Faq {
late int faqId;
late String name;
late String description;
int? sort;
HashMap<String, String> nameTranslations = HashMap();
HashMap<String, String> descriptionTranslations = HashMap();
Faq.fromJson(Map json) {
this.faqId = json['faqId'];
this.name = json['name'];
this.description = json['description'];
this.sort = json['sort'];
nameTranslations['en'] = name;
descriptionTranslations['en'] = description;
if (json['translations'] != null && json['translations'].length > 0) {
json['translations'].forEach((translation) {
nameTranslations[translation['languageCode']] = translation['nameTranslation'];
descriptionTranslations[translation['languageCode']] = translation['descriptionTranslation'];
});
}
}
Map<String, dynamic> toJson() => {
"faqId": this.faqId,
"name": this.name,
"description": this.description,
"nameTranslation": this.nameTranslations.toString(),
};
@override
String toString() => this.toJson().toString();
}