2023-03-02 13:19:08 +01:00
|
|
|
import 'package:smoke_cess_app/interface/db_record.dart';
|
|
|
|
|
|
|
|
class Workout implements DatabaseRecord {
|
|
|
|
int _motivationBefore;
|
|
|
|
int _motivationAfter;
|
|
|
|
DateTime _workoutDate;
|
|
|
|
|
|
|
|
Workout(this._motivationBefore, this._motivationAfter, this._workoutDate);
|
|
|
|
|
2023-03-02 18:35:03 +01:00
|
|
|
DateTime get date => _workoutDate;
|
2023-03-03 12:47:54 +01:00
|
|
|
int get motivationBefore => _motivationBefore;
|
|
|
|
int get motivationAfter => _motivationAfter;
|
2023-03-02 18:35:03 +01:00
|
|
|
|
2023-03-02 13:19:08 +01:00
|
|
|
@override
|
2023-03-02 18:35:03 +01:00
|
|
|
factory Workout.fromDatabase(Map<String, dynamic> map) {
|
2023-03-02 19:04:40 +01:00
|
|
|
return Workout(map['motivationBefore'], map['motivationAfter'],
|
|
|
|
DateTime.parse(map['workoutDate']));
|
|
|
|
}
|
|
|
|
|
2023-03-02 13:19:08 +01:00
|
|
|
@override
|
|
|
|
factory Workout.fromMap(Map<String, dynamic> map) {
|
2023-03-02 19:04:40 +01:00
|
|
|
return Workout(
|
|
|
|
map['motivationBefore'], map['motivationAfter'], map['workoutDate']);
|
2023-03-02 13:19:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toCSV() =>
|
|
|
|
"${_workoutDate.toIso8601String()}, $_motivationBefore, $_motivationAfter";
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
'motivationBefore': _motivationBefore,
|
|
|
|
'motivationAfter': _motivationAfter,
|
2023-03-02 19:43:05 +01:00
|
|
|
'workoutDate': _workoutDate.toIso8601String(),
|
2023-03-02 13:19:08 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|