37 lines
977 B
Dart
37 lines
977 B
Dart
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);
|
|
|
|
DateTime get date => _workoutDate;
|
|
|
|
@override
|
|
factory Workout.fromDatabase(Map<String, dynamic> map) {
|
|
return Workout(map['motivationBefore'], map['motivationAfter'],
|
|
DateTime.parse(map['workoutDate']));
|
|
}
|
|
|
|
@override
|
|
factory Workout.fromMap(Map<String, dynamic> map) {
|
|
return Workout(
|
|
map['motivationBefore'], map['motivationAfter'], map['workoutDate']);
|
|
}
|
|
|
|
@override
|
|
String toCSV() =>
|
|
"${_workoutDate.toIso8601String()}, $_motivationBefore, $_motivationAfter";
|
|
|
|
@override
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'motivationBefore': _motivationBefore,
|
|
'motivationAfter': _motivationAfter,
|
|
'workoutDate': _workoutDate.toIso8601String(),
|
|
};
|
|
}
|
|
}
|