32 lines
696 B
Dart
32 lines
696 B
Dart
import 'package:smoke_cess_app/interface/db_record.dart';
|
|
|
|
class Mood implements DatabaseRecord {
|
|
final int _moodValue;
|
|
final String _comment;
|
|
final DateTime _date;
|
|
|
|
Mood(this._moodValue, this._comment, this._date);
|
|
|
|
DateTime get date => _date;
|
|
|
|
@override
|
|
factory Mood.fromDatabase(Map<String, dynamic> map) {
|
|
DateTime date = DateTime.parse(map['date']);
|
|
return Mood(map['value'], map['comment'], date);
|
|
}
|
|
|
|
@override
|
|
String toCSV() {
|
|
return "${_date.toIso8601String()}, $_moodValue, $_comment";
|
|
}
|
|
|
|
@override
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'value': _moodValue,
|
|
'comment': _comment,
|
|
'date': _date.toIso8601String(),
|
|
};
|
|
}
|
|
}
|