diff --git a/BeReadyBackend/Endpoints/Groups/GetAllProofsEndpoint.cs b/BeReadyBackend/Endpoints/Groups/GetAllProofsEndpoint.cs index ad55c5e..0d45a81 100644 --- a/BeReadyBackend/Endpoints/Groups/GetAllProofsEndpoint.cs +++ b/BeReadyBackend/Endpoints/Groups/GetAllProofsEndpoint.cs @@ -20,7 +20,7 @@ public class GetAllProofsEndpoint(UserGroupsRepository userGroupsRepository, Gro public override async Task HandleAsync(GroupProofRequest req, CancellationToken ct) { - Group? group = await groupsRepository.SingleOrDefaultAsync(new GetGroupByIdSpec(req.Id), ct); + Group? group = await groupsRepository.SingleOrDefaultAsync(new GetGroupByIdSpec(req.Id), ct); if (group is null) { await Send.NotFoundAsync(ct); @@ -32,7 +32,7 @@ public class GetAllProofsEndpoint(UserGroupsRepository userGroupsRepository, Gro await Send.StringAsync("Les votes ne sont pas fini", 400, cancellation: ct); return; } - + List usersGroup = await userGroupsRepository.ProjectToListAsync(new GetUserGroupDetailsByIdSpec(req.Id), ct); await Send.OkAsync(usersGroup, ct); } diff --git a/BeReadyBackend/Endpoints/Groups/PatchVoteEndpoint.cs b/BeReadyBackend/Endpoints/Groups/PatchVoteEndpoint.cs index 9a6942f..20856fb 100644 --- a/BeReadyBackend/Endpoints/Groups/PatchVoteEndpoint.cs +++ b/BeReadyBackend/Endpoints/Groups/PatchVoteEndpoint.cs @@ -41,7 +41,7 @@ public class PatchVoteEndpoint(UserGroupsRepository userGroupsRepository, UserSe await Send.StringAsync("Le vote est terminé", 400, cancellation: ct); return; } - + if (member.Group!.StartedVote is null) { await Send.StringAsync("Le vote n'a pas commencé", 400, cancellation: ct); diff --git a/BeReadyBackend/Endpoints/Groups/StartVoteEndpoint.cs b/BeReadyBackend/Endpoints/Groups/StartVoteEndpoint.cs index 493fb42..51e841c 100644 --- a/BeReadyBackend/Endpoints/Groups/StartVoteEndpoint.cs +++ b/BeReadyBackend/Endpoints/Groups/StartVoteEndpoint.cs @@ -31,7 +31,7 @@ public class StartVoteEndpoint(UserGroupsRepository userGroupsRepository, Groups await Send.NotFoundAsync(ct); return; } - + if (group.IsFinished) { await Send.StringAsync("Le défi est terminé", 400, cancellation: ct); @@ -43,7 +43,7 @@ public class StartVoteEndpoint(UserGroupsRepository userGroupsRepository, Groups await Send.StringAsync("Le défi n'est pas encore terminé", 400, cancellation: ct); return; } - + group.StartedVote = DateTime.Now; await groupsRepository.SaveChangesAsync(ct); diff --git a/BeReadyBackend/Endpoints/Messages/SendMessageEndpoint.cs b/BeReadyBackend/Endpoints/Messages/SendMessageEndpoint.cs index 1c4649e..04eba3a 100644 --- a/BeReadyBackend/Endpoints/Messages/SendMessageEndpoint.cs +++ b/BeReadyBackend/Endpoints/Messages/SendMessageEndpoint.cs @@ -11,10 +11,10 @@ using Group = System.Text.RegularExpressions.Group; namespace BeReadyBackend.Endpoints.Messages; public class SendMessageEndpoint( - UserService userService, - GroupsRepository groupsRepository, - AutoMapper.IMapper mapper, - MessagesRepository messagesRepository, + UserService userService, + GroupsRepository groupsRepository, + AutoMapper.IMapper mapper, + MessagesRepository messagesRepository, IHubContext hubContext) : Endpoint { @@ -37,7 +37,7 @@ public class SendMessageEndpoint( await Send.StringAsync("Le groupe est fermé", 400, cancellation: ct); return; } - + Message message = new(); mapper.Map(req, message); message.UserId = userService.GetUserIdFromToken(); diff --git a/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs b/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs index c062a11..0d2709c 100644 --- a/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs +++ b/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs @@ -28,7 +28,7 @@ public class PatchProofEndpoint( public override async Task HandleAsync(RandomChallengeProofRequest req, CancellationToken ct) { int userId = userService.GetUserIdFromToken(); - + RandomChallenge? randomChallenge = await randomChallengesRepository.SingleOrDefaultAsync(new GetRandomChallengeByIdSpec(req.RandomChallengeId), ct); if (randomChallenge is null) { @@ -38,10 +38,10 @@ public class PatchProofEndpoint( if (randomChallenge.GeneratedAt != null && DateTime.Now > randomChallenge.GeneratedAt.Value.AddHours(randomChallenge.Duration)) { - await Send.StringAsync("Le défi est terminé", 400, cancellation: ct); + await Send.StringAsync("Le défi est terminé", 400, cancellation: ct); return; } - + UserRandomChallenge? userRandomChallenge = await userRandomChallengesRepository.SingleOrDefaultAsync(new GetRandomChallengeByCriteriaSpec(req.RandomChallengeId, userId), ct); if (userRandomChallenge is null) diff --git a/BeReadyBackend/Models/RandomChallenge.cs b/BeReadyBackend/Models/RandomChallenge.cs index 357fd06..9cca111 100644 --- a/BeReadyBackend/Models/RandomChallenge.cs +++ b/BeReadyBackend/Models/RandomChallenge.cs @@ -8,7 +8,7 @@ public class RandomChallenge [Required, Length(2, 200)] public string? Libelle { get; set; } [Required] public int Duration { get; set; } [Required] public bool IsAlreadyPast { get; set; } - + [Required] public DateTime? GeneratedAt { get; set; } public List? UserRandomChallenges { get; set; } diff --git a/BeReadyBackend/Validators/Achievements/GetAchievementDtoValidator.cs b/BeReadyBackend/Validators/Achievements/GetAchievementDtoValidator.cs index ec9a653..ee25428 100644 --- a/BeReadyBackend/Validators/Achievements/GetAchievementDtoValidator.cs +++ b/BeReadyBackend/Validators/Achievements/GetAchievementDtoValidator.cs @@ -19,7 +19,7 @@ public class GetAchievementDtoValidator : Validator .WithMessage("Description must contain more than 2 characters") .MaximumLength(200) .WithMessage("Description cannot contain more than 200 characters"); - + RuleFor(x => x.Label) .NotEmpty() .WithMessage("Label must be specified") diff --git a/BeReadyBackend/Validators/Achievements/UnlockAchievementDtoValidator.cs b/BeReadyBackend/Validators/Achievements/UnlockAchievementDtoValidator.cs index 453d0fb..2f5d04f 100644 --- a/BeReadyBackend/Validators/Achievements/UnlockAchievementDtoValidator.cs +++ b/BeReadyBackend/Validators/Achievements/UnlockAchievementDtoValidator.cs @@ -13,6 +13,5 @@ public class UnlockAchievementDtoValidator : Validator .WithMessage("AchievementId cannot be empty") .GreaterThan(0) .WithMessage("AchievementId must be greater than 0"); - } } \ No newline at end of file diff --git a/BeReadyBackend/Validators/Auth/LoginDtoValidator.cs b/BeReadyBackend/Validators/Auth/LoginDtoValidator.cs index da5284a..d3e7041 100644 --- a/BeReadyBackend/Validators/Auth/LoginDtoValidator.cs +++ b/BeReadyBackend/Validators/Auth/LoginDtoValidator.cs @@ -4,7 +4,7 @@ using FluentValidation; namespace BeReadyBackend.Validators.Auth; -public class LoginDtoValidator: Validator +public class LoginDtoValidator : Validator { public LoginDtoValidator() { diff --git a/BeReadyBackend/Validators/Friends/GetFriendDtoValidator.cs b/BeReadyBackend/Validators/Friends/GetFriendDtoValidator.cs index 9074d15..c13f421 100644 --- a/BeReadyBackend/Validators/Friends/GetFriendDtoValidator.cs +++ b/BeReadyBackend/Validators/Friends/GetFriendDtoValidator.cs @@ -6,7 +6,7 @@ namespace BeReadyBackend.Validators.Friends; public class GetFriendDtoValidator : Validator { - public GetFriendDtoValidator() + public GetFriendDtoValidator() { RuleFor(x => x.Username) .NotEmpty() diff --git a/BeReadyBackend/Validators/Friends/GetFriendRequestDtoValidator.cs b/BeReadyBackend/Validators/Friends/GetFriendRequestDtoValidator.cs index 8e3dbb6..2557fce 100644 --- a/BeReadyBackend/Validators/Friends/GetFriendRequestDtoValidator.cs +++ b/BeReadyBackend/Validators/Friends/GetFriendRequestDtoValidator.cs @@ -6,7 +6,7 @@ namespace BeReadyBackend.Validators.Friends; public class GetFriendRequestDtoValidator : Validator { - public GetFriendRequestDtoValidator() + public GetFriendRequestDtoValidator() { RuleFor(x => x.Username) .NotEmpty() diff --git a/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs b/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs index 6be0d0d..780f379 100644 --- a/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs +++ b/BeReadyBackend/Validators/Groups/CreateGroupDtoValidator.cs @@ -31,7 +31,7 @@ public class CreateGroupDtoValidator : Validator .WithMessage("Description cannot exceed 200 characters") .MinimumLength(2) .WithMessage("Description must exceed 2 characters"); - + RuleFor(x => x.Duration) .NotEmpty() .WithMessage("Duration cannot be empty") diff --git a/BeReadyBackend/Validators/Groups/GetGroupDetailsDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetGroupDetailsDtoValidator.cs index 7dbc813..d36c97b 100644 --- a/BeReadyBackend/Validators/Groups/GetGroupDetailsDtoValidator.cs +++ b/BeReadyBackend/Validators/Groups/GetGroupDetailsDtoValidator.cs @@ -13,7 +13,7 @@ public class GetGroupDetailsDtoValidator : Validator .WithMessage("Id cannot be empty") .GreaterThan(0) .WithMessage("Id must be greater than zero"); - + RuleFor(x => x.Label) .NotEmpty() .WithMessage("Label cannot be empty") @@ -41,7 +41,7 @@ public class GetGroupDetailsDtoValidator : Validator .WithMessage("Description cannot exceed 50 characters") .MinimumLength(2) .WithMessage("Description must exceed 2 characters"); - + RuleFor(x => x.Duration) .NotEmpty() .WithMessage("Duration cannot be empty") diff --git a/BeReadyBackend/Validators/Groups/GetGroupDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetGroupDtoValidator.cs index a3427e6..c2d16e3 100644 --- a/BeReadyBackend/Validators/Groups/GetGroupDtoValidator.cs +++ b/BeReadyBackend/Validators/Groups/GetGroupDtoValidator.cs @@ -13,7 +13,7 @@ public class GetGroupDtoValidator : Validator .WithMessage("Id cannot be empty") .GreaterThan(0) .WithMessage("Id must be greater than zero"); - + RuleFor(x => x.Label) .NotEmpty() .WithMessage("Label cannot be empty") diff --git a/BeReadyBackend/Validators/Groups/GetProofDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetProofDtoValidator.cs index cb24ca8..2ba1155 100644 --- a/BeReadyBackend/Validators/Groups/GetProofDtoValidator.cs +++ b/BeReadyBackend/Validators/Groups/GetProofDtoValidator.cs @@ -13,7 +13,7 @@ public class GetProofDtoValidator : Validator .WithMessage("Id cannot be empty") .GreaterThan(0) .WithMessage("Id must be greater than 0"); - + RuleFor(x => x.Username) .NotEmpty() .WithMessage("Username cannot be empty") @@ -25,7 +25,7 @@ public class GetProofDtoValidator : Validator RuleFor(x => x.Proof) .NotEmpty() .WithMessage("Proof cannot be empty"); - + RuleFor(x => x.Score) .NotEmpty() .WithMessage("Score cannot be empty"); diff --git a/BeReadyBackend/Validators/Groups/GetUserGroupDtoValidator.cs b/BeReadyBackend/Validators/Groups/GetUserGroupDtoValidator.cs index b290ebe..0d508ae 100644 --- a/BeReadyBackend/Validators/Groups/GetUserGroupDtoValidator.cs +++ b/BeReadyBackend/Validators/Groups/GetUserGroupDtoValidator.cs @@ -13,7 +13,7 @@ public class GetUserGroupDtoValidator : Validator .WithMessage("Id cannot be empty") .GreaterThan(0) .WithMessage("Id must be greater than 0"); - + RuleFor(x => x.Username) .NotEmpty() .WithMessage("Username cannot be empty") @@ -25,7 +25,7 @@ public class GetUserGroupDtoValidator : Validator RuleFor(x => x.Grade) .NotEmpty() .WithMessage("Grade cannot be empty"); - + RuleFor(x => x.Score) .NotEmpty() .WithMessage("Score cannot be empty"); diff --git a/BeReadyBackend/Validators/RandomChallenges/GetRandomChallengeDtoValidator.cs b/BeReadyBackend/Validators/RandomChallenges/GetRandomChallengeDtoValidator.cs index 472c4a4..5f001b4 100644 --- a/BeReadyBackend/Validators/RandomChallenges/GetRandomChallengeDtoValidator.cs +++ b/BeReadyBackend/Validators/RandomChallenges/GetRandomChallengeDtoValidator.cs @@ -15,7 +15,7 @@ public class GetRandomChallengeDtoValidator : Validator .WithMessage("Libelle cannot exceed 200 characters") .MinimumLength(2) .WithMessage("Libelle must exceed 2 characters"); - + RuleFor(x => x.Duration) .NotEmpty() .WithMessage("Duration cannot be empty") diff --git a/BeReadyBackend/Validators/Users/CreateUserDtoValidator.cs b/BeReadyBackend/Validators/Users/CreateUserDtoValidator.cs index bcf4d83..4ff6421 100644 --- a/BeReadyBackend/Validators/Users/CreateUserDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/CreateUserDtoValidator.cs @@ -44,7 +44,7 @@ public class CreateUserDtoValidator : Validator .NotEmpty() .WithMessage("Password is required") .MaximumLength(60) - .WithMessage("Password cannot exceed 60 characters") + .WithMessage("Password cannot exceed 60 characters") .MinimumLength(12) .WithMessage("Password must exceed 12 characters"); } diff --git a/BeReadyBackend/Validators/Users/GetUserChallengeDtoValidator.cs b/BeReadyBackend/Validators/Users/GetUserChallengeDtoValidator.cs index 91e5bb4..aaf5161 100644 --- a/BeReadyBackend/Validators/Users/GetUserChallengeDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/GetUserChallengeDtoValidator.cs @@ -6,14 +6,14 @@ namespace BeReadyBackend.Validators.Users; public class GetUserChallengeDtoValidator : Validator { - public GetUserChallengeDtoValidator() + public GetUserChallengeDtoValidator() { RuleFor(x => x.ChallengeTitle) .NotEmpty() .WithMessage("Challenge Title is required") .MaximumLength(200) .WithMessage("Challenge Title cannot exceed 200 characters"); - + RuleFor(x => x.ChallengeDescription) .NotEmpty() .WithMessage("Challenge Description is required") diff --git a/BeReadyBackend/Validators/Users/GetUserDetailsDtoValidator.cs b/BeReadyBackend/Validators/Users/GetUserDetailsDtoValidator.cs index 0a85e24..b956657 100644 --- a/BeReadyBackend/Validators/Users/GetUserDetailsDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/GetUserDetailsDtoValidator.cs @@ -6,7 +6,7 @@ namespace BeReadyBackend.Validators.Users; public class GetUserDetailsDtoValidator : Validator { - public GetUserDetailsDtoValidator() + public GetUserDetailsDtoValidator() { RuleFor(x => x.FirstName) .NotEmpty() @@ -15,7 +15,7 @@ public class GetUserDetailsDtoValidator : Validator .WithMessage("First name cannot not exceed 50 characters") .MinimumLength(50) .WithMessage("First name must not exceed 50 characters"); - + RuleFor(x => x.Name) .NotEmpty() .WithMessage("Name is required") @@ -43,7 +43,7 @@ public class GetUserDetailsDtoValidator : Validator RuleFor(x => x.CreationDate) .NotEmpty() .WithMessage("CreationDate is required"); - + When(x => x.DesignationId is not null, () => { RuleFor(x => x.DesignationId) diff --git a/BeReadyBackend/Validators/Users/GetUserDtoValidator.cs b/BeReadyBackend/Validators/Users/GetUserDtoValidator.cs index 2970da7..f0a5950 100644 --- a/BeReadyBackend/Validators/Users/GetUserDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/GetUserDtoValidator.cs @@ -6,14 +6,14 @@ namespace BeReadyBackend.Validators.Users; public class GetUserDtoValidator : Validator { - public GetUserDtoValidator() { - + public GetUserDtoValidator() + { RuleFor(x => x.Id) .NotEmpty() .WithMessage("Id cannot be empty") .GreaterThan(0) .WithMessage("Id must be greater than 0"); - + RuleFor(x => x.FirstName) .NotEmpty() .WithMessage("First name is required") @@ -37,7 +37,7 @@ public class GetUserDtoValidator : Validator .WithMessage("Username cannot exceed 50 characters") .MinimumLength(2) .WithMessage("Username must exceed 2 characters"); - + When(x => x.DesignationId is not null, () => { RuleFor(x => x.DesignationId) diff --git a/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs b/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs index 61acaa6..cb52b71 100644 --- a/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs @@ -13,7 +13,7 @@ public class GetUserProofDtoValidator : Validator .WithMessage("Id cannot be empty") .GreaterThan(0) .WithMessage("Id must be greater than 0"); - + RuleFor(x => x.Proof) .NotEmpty() .WithMessage("Proof cannot be empty"); diff --git a/BeReadyBackend/Validators/Users/GetUserStatsDtoValidator.cs b/BeReadyBackend/Validators/Users/GetUserStatsDtoValidator.cs index 3954bf9..1f6d7e3 100644 --- a/BeReadyBackend/Validators/Users/GetUserStatsDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/GetUserStatsDtoValidator.cs @@ -6,30 +6,30 @@ namespace BeReadyBackend.Validators.Users; public class GetUserStatsDtoValidator : Validator { - public GetUserStatsDtoValidator() - { - RuleFor(x => x.Score) - .NotEmpty() - .WithMessage("Score is required"); - - RuleFor(x => x.TotalWin) - .NotEmpty() - .WithMessage("Total win is required"); - - RuleFor(x=> x.TotalChallenge) - .NotEmpty() - .WithMessage("Total challenge is required"); - - RuleFor(x => x.TotalPodium) - .NotEmpty() - .WithMessage("Total podium is required"); - - RuleFor(x => x.TotalBonusChallenge) - .NotEmpty() - .WithMessage("Total bonus is required"); - - RuleFor(x => x.Series) - .NotEmpty() - .WithMessage("Series is required"); - } + public GetUserStatsDtoValidator() + { + RuleFor(x => x.Score) + .NotEmpty() + .WithMessage("Score is required"); + + RuleFor(x => x.TotalWin) + .NotEmpty() + .WithMessage("Total win is required"); + + RuleFor(x => x.TotalChallenge) + .NotEmpty() + .WithMessage("Total challenge is required"); + + RuleFor(x => x.TotalPodium) + .NotEmpty() + .WithMessage("Total podium is required"); + + RuleFor(x => x.TotalBonusChallenge) + .NotEmpty() + .WithMessage("Total bonus is required"); + + RuleFor(x => x.Series) + .NotEmpty() + .WithMessage("Series is required"); + } } \ No newline at end of file diff --git a/BeReadyBackend/Validators/Users/UpdateUserDtoValidator.cs b/BeReadyBackend/Validators/Users/UpdateUserDtoValidator.cs index fdb6c9a..1489630 100644 --- a/BeReadyBackend/Validators/Users/UpdateUserDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/UpdateUserDtoValidator.cs @@ -6,7 +6,7 @@ namespace BeReadyBackend.Validators.Users; public class UpdateUserDtoValidator : Validator { - public UpdateUserDtoValidator() + public UpdateUserDtoValidator() { RuleFor(x => x.FirstName) .NotEmpty() @@ -23,7 +23,7 @@ public class UpdateUserDtoValidator : Validator .WithMessage("Name cannot exceed 50 characters") .MinimumLength(2) .WithMessage("Name must exceed 2 characters"); - + RuleFor(x => x.Username) .NotEmpty() .WithMessage("Username is required")