Adding match endpoints, services and providers, additionally added a page in the frontend that displays the data
This commit is contained in:
46
frontend_splatournament_manager/lib/models/match.dart
Normal file
46
frontend_splatournament_manager/lib/models/match.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
class Match {
|
||||
final int id;
|
||||
final int tournamentId;
|
||||
final int round;
|
||||
final int matchNumber;
|
||||
final int? team1Id;
|
||||
final int? team2Id;
|
||||
final int? winnerId;
|
||||
|
||||
Match({
|
||||
required this.id,
|
||||
required this.tournamentId,
|
||||
required this.round,
|
||||
required this.matchNumber,
|
||||
this.team1Id,
|
||||
this.team2Id,
|
||||
this.winnerId,
|
||||
});
|
||||
|
||||
factory Match.fromJson(Map<String, dynamic> json) {
|
||||
return Match(
|
||||
id: json['id'],
|
||||
tournamentId: json['tournamentId'],
|
||||
round: json['round'],
|
||||
matchNumber: json['matchNumber'],
|
||||
team1Id: json['team1Id'],
|
||||
team2Id: json['team2Id'],
|
||||
winnerId: json['winnerId'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'tournamentId': tournamentId,
|
||||
'round': round,
|
||||
'matchNumber': matchNumber,
|
||||
'team1Id': team1Id,
|
||||
'team2Id': team2Id,
|
||||
'winnerId': winnerId,
|
||||
};
|
||||
}
|
||||
|
||||
bool get hasWinner => winnerId != null;
|
||||
bool get canBePlayed => team1Id != null && team2Id != null;
|
||||
}
|
||||
Reference in New Issue
Block a user