cpd_2022_zi/lib/models/relapse.dart

29 lines
654 B
Dart
Raw Normal View History

2023-02-26 23:24:23 +01:00
import 'package:smoke_cess_app/interface/db_record.dart';
class Relapse implements DatabaseRecord {
2023-02-27 02:28:26 +01:00
final String _category;
2023-02-26 23:24:23 +01:00
final String _comment;
final DateTime _date;
2023-02-27 02:28:26 +01:00
Relapse(this._category, this._comment, this._date);
2023-02-26 23:24:23 +01:00
@override
factory Relapse.fromDatabase(Map<String, dynamic> map) {
DateTime date = DateTime.parse(map['date']);
2023-02-27 02:28:26 +01:00
return Relapse(map['_category'], map['comment'], date);
2023-02-26 23:24:23 +01:00
}
@override
String toCSV() {
2023-02-27 02:28:26 +01:00
return "${_date.toIso8601String()}, $_category, $_comment";
2023-02-26 23:24:23 +01:00
}
@override
Map<String, dynamic> toMap() {
return {
'comment': _comment,
'date': _date.toIso8601String(),
};
}
}