45 lines
972 B
Dart
45 lines
972 B
Dart
// lib/models/entry.dart
|
|
import 'event.dart';
|
|
import 'event.dart';
|
|
import 'team.dart';
|
|
import 'category.dart';
|
|
|
|
class Entry {
|
|
final int id;
|
|
final Team team;
|
|
final Event event;
|
|
final NewCategory category;
|
|
final DateTime date;
|
|
final String owner;
|
|
|
|
Entry({
|
|
required this.id,
|
|
required this.team,
|
|
required this.event,
|
|
required this.category,
|
|
required this.date,
|
|
required this.owner,
|
|
});
|
|
|
|
factory Entry.fromJson(Map<String, dynamic> json) {
|
|
return Entry(
|
|
id: json['id'],
|
|
team: Team.fromJson(json['team']),
|
|
event: Event.fromJson(json['event']),
|
|
category: NewCategory.fromJson(json['category']),
|
|
date: DateTime.parse(json['date']),
|
|
owner: json['owner'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'team': team.toJson(),
|
|
'event': event.toJson(),
|
|
'category': category.toJson(),
|
|
'date': date.toIso8601String(),
|
|
'owner': owner,
|
|
};
|
|
}
|
|
} |