From 1e25ca809b2cfd9d8f79ecc8ed9329363506e96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Gol=C3=A1=C5=88=20jr?= Date: Fri, 10 Apr 2026 15:56:45 +0200 Subject: [PATCH] fix: cleanup unnecessary usings --- TournamentOrganizer/Models/Game.cs | 1 - TournamentOrganizer/Models/Match.cs | 1 - TournamentOrganizer/Models/Participant.cs | 4 ---- TournamentOrganizer/Models/Round.cs | 1 - TournamentOrganizer/Models/Team.cs | 1 - TournamentOrganizer/Models/Tournament.cs | 12 ++++++++++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/TournamentOrganizer/Models/Game.cs b/TournamentOrganizer/Models/Game.cs index 979fa0a..d7994d8 100644 --- a/TournamentOrganizer/Models/Game.cs +++ b/TournamentOrganizer/Models/Game.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/TournamentOrganizer/Models/Match.cs b/TournamentOrganizer/Models/Match.cs index 80b9507..b2be3cc 100644 --- a/TournamentOrganizer/Models/Match.cs +++ b/TournamentOrganizer/Models/Match.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/TournamentOrganizer/Models/Participant.cs b/TournamentOrganizer/Models/Participant.cs index 25eaa39..efc3ab0 100644 --- a/TournamentOrganizer/Models/Participant.cs +++ b/TournamentOrganizer/Models/Participant.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore; namespace TournamentOrganizer.Models; diff --git a/TournamentOrganizer/Models/Round.cs b/TournamentOrganizer/Models/Round.cs index dbbdb46..801fba7 100644 --- a/TournamentOrganizer/Models/Round.cs +++ b/TournamentOrganizer/Models/Round.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/TournamentOrganizer/Models/Team.cs b/TournamentOrganizer/Models/Team.cs index 5a066ff..41fc113 100644 --- a/TournamentOrganizer/Models/Team.cs +++ b/TournamentOrganizer/Models/Team.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/TournamentOrganizer/Models/Tournament.cs b/TournamentOrganizer/Models/Tournament.cs index 9c2baf9..9af875d 100644 --- a/TournamentOrganizer/Models/Tournament.cs +++ b/TournamentOrganizer/Models/Tournament.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; namespace TournamentOrganizer.Models; @@ -13,7 +11,9 @@ public class Tournament public int Id { get; set; } public int GameId { get; set; } public int EventId { get; set; } + [CustomValidation(typeof(Tournament), nameof(ValidateDates))] public DateTime Start { get; set; } + [CustomValidation(typeof(Tournament), nameof(ValidateDates))] public DateTime End { get; set; } public RuleSet S1RuleSet { get; set; } @@ -24,4 +24,12 @@ public class Tournament public required Game Game { get; set; } public required Event Event { get; set; } + public static ValidationResult ValidateDates(DateTime date, ValidationContext context) + { + Tournament instance = (Tournament)context.ObjectInstance; + if (date >= instance.Event.Start && date <= instance.Event.End) + return ValidationResult.Success; + return new("Tournament must take place during the event."); + } + } \ No newline at end of file