workouttest_util/lib/model/faq.dart
2023-02-12 22:42:51 +01:00

38 lines
1.0 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) {
faqId = json['faqId'];
name = json['name'];
description = json['description'];
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": faqId,
"name": name,
"description": description,
"nameTranslation": nameTranslations.toString(),
};
@override
String toString() => toJson().toString();
}