Files
WMC-Project-5/frontend_splatournament_manager/lib/models/tournament.dart
2026-03-06 23:48:48 +01:00

51 lines
1.4 KiB
Dart

class Tournament {
final int id;
final String name;
final String description;
final int maxTeamAmount;
final int currentTeamAmount;
final String registrationStartDate;
final String registrationEndDate;
Tournament({
required this.id,
required this.name,
required this.description,
required this.maxTeamAmount,
required this.currentTeamAmount,
required this.registrationStartDate,
required this.registrationEndDate,
});
factory Tournament.fromJson(dynamic json) {
return Tournament(
id: json['id'],
name: json['name'],
description: json['description'],
maxTeamAmount: json['maxTeamAmount'],
currentTeamAmount: json['currentTeamAmount'],
registrationStartDate: json['registrationStartDate'],
registrationEndDate: json['registrationEndDate'],
);
}
bool get isRegistrationOpen {
final now = DateTime.now();
final startDate = DateTime.parse(registrationStartDate);
final endDate = DateTime.parse(registrationEndDate);
return now.isAfter(startDate) && now.isBefore(endDate);
}
bool get isRegistrationPast {
final now = DateTime.now();
final endDate = DateTime.parse(registrationEndDate);
return now.isAfter(endDate);
}
bool get isRegistrationFuture {
final now = DateTime.now();
final startDate = DateTime.parse(registrationStartDate);
return now.isBefore(startDate);
}
}