48 lines
1.6 KiB
Dart
48 lines
1.6 KiB
Dart
import 'package:hiddingsel_app/appflow/model/schedules.dart';
|
|
import 'package:hiddingsel_app/services/storage.dart';
|
|
|
|
import 'contacts.dart';
|
|
import 'event_organisations.dart';
|
|
import 'interfaces.dart';
|
|
|
|
class EventModel with Name, Contact, JsonEncodable {
|
|
|
|
final String id;
|
|
final ScheduleModel schedule;
|
|
final String name;
|
|
final ContactModel contact;
|
|
final String? description;
|
|
List<EventOrganisationModel> eventOrganizer;
|
|
|
|
EventModel(this.id, this.schedule, this.name, this.contact,
|
|
{this.description, List<EventOrganisationModel>? eventOrganizer})
|
|
: this.eventOrganizer = eventOrganizer ?? [];
|
|
|
|
factory EventModel.fromJson(Map<String, dynamic> json) => EventModel(
|
|
json['id'] as String,
|
|
ScheduleModel.fromJson(json['schedule'] as Map<String, dynamic>),
|
|
json['name'] as String,
|
|
ContactModel.fromJson(json['contact'] as Map<String, dynamic>),
|
|
description: json['description'] as String?,
|
|
eventOrganizer: (json['eventOrganizer'] as List<dynamic>).map((id) => EventOrganisationModel.fromId(id)).cast<EventOrganisationModel>().toList(),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'schedule': schedule.toJson(),
|
|
'name': name,
|
|
'contact': contact.toJson(),
|
|
'description': description,
|
|
'eventOrganizer': eventOrganizer.map((e) => e.id).toList(),
|
|
};
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
other is EventModel &&
|
|
runtimeType == other.runtimeType &&
|
|
(id == other.id || (schedule.startTime == other.schedule.startTime && name == other.name));
|
|
|
|
@override
|
|
int get hashCode => id.hashCode;
|
|
}
|