2023-02-16 01:59:15 +01:00
|
|
|
import 'package:smoke_cess_app/interface/db_record.dart';
|
|
|
|
|
|
|
|
class Mood implements DatabaseRecord {
|
2023-02-25 18:54:23 +01:00
|
|
|
final int _moodValue;
|
2023-02-16 01:59:15 +01:00
|
|
|
final String _comment;
|
|
|
|
final DateTime _date;
|
|
|
|
|
|
|
|
Mood(this._moodValue, this._comment, this._date);
|
|
|
|
|
2023-02-25 18:54:23 +01:00
|
|
|
@override
|
|
|
|
factory Mood.fromDatabase(Map<String, dynamic> map) {
|
|
|
|
DateTime date = DateTime.parse(map['date']);
|
|
|
|
return Mood(map['value'], map['comment'], date);
|
|
|
|
}
|
|
|
|
|
2023-02-16 01:59:15 +01:00
|
|
|
@override
|
|
|
|
String toCSV() {
|
2023-02-25 18:54:23 +01:00
|
|
|
return "${_date.toIso8601String()}, $_moodValue, $_comment";
|
2023-02-16 01:59:15 +01:00
|
|
|
}
|
2023-02-22 01:28:01 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
2023-02-25 15:30:04 +01:00
|
|
|
'value': _moodValue,
|
2023-02-22 01:28:01 +01:00
|
|
|
'comment': _comment,
|
2023-02-25 15:30:04 +01:00
|
|
|
'date': _date.toIso8601String(),
|
2023-02-22 01:28:01 +01:00
|
|
|
};
|
|
|
|
}
|
2023-02-16 01:59:15 +01:00
|
|
|
}
|