From d048d78cb299c08dc0b78fd957a0970517f886cb Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Thu, 16 Apr 2026 15:55:13 +0100 Subject: [PATCH] Fixed error of mapping with proofs --- BeReadyBackend/DTO/Users/GetUserProofDto.cs | 3 +-- .../Endpoints/Users/GetAllUserProofsEndpoint.cs | 12 +++++++++--- .../Validators/Users/GetUserProofDtoValidator.cs | 6 ------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/BeReadyBackend/DTO/Users/GetUserProofDto.cs b/BeReadyBackend/DTO/Users/GetUserProofDto.cs index 8515b8c..21d938b 100644 --- a/BeReadyBackend/DTO/Users/GetUserProofDto.cs +++ b/BeReadyBackend/DTO/Users/GetUserProofDto.cs @@ -1,7 +1,6 @@ namespace BeReadyBackend.DTO.Users; public class GetUserProofDto -{ - public int Id { get; set; } +{ public string? Proof { get; set; } } \ No newline at end of file diff --git a/BeReadyBackend/Endpoints/Users/GetAllUserProofsEndpoint.cs b/BeReadyBackend/Endpoints/Users/GetAllUserProofsEndpoint.cs index 30c0f3d..7a89149 100644 --- a/BeReadyBackend/Endpoints/Users/GetAllUserProofsEndpoint.cs +++ b/BeReadyBackend/Endpoints/Users/GetAllUserProofsEndpoint.cs @@ -7,7 +7,7 @@ using FastEndpoints; namespace BeReadyBackend.Endpoints.Users; -public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserService userService, AutoMapper.IMapper mapper) : EndpointWithoutRequest> +public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserService userService) : EndpointWithoutRequest> { public override void Configure() { @@ -31,12 +31,18 @@ public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserServi proofs.AddRange( user.UserRandomChallenges .Where(x => x.Proof is not null) - .Select(x => mapper.Map(x.RandomChallenge)) + .Select(x => new GetUserProofDto + { + Proof = x.Proof + }) ); if (user.UserGroups is not null) proofs.AddRange( - user.UserGroups.Select(x => mapper.Map(x.Group)) + user.UserGroups.Select(x => new GetUserProofDto + { + Proof = x.Proof + }) ); await Send.OkAsync(proofs, ct); diff --git a/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs b/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs index cb52b71..5fddbbc 100644 --- a/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs +++ b/BeReadyBackend/Validators/Users/GetUserProofDtoValidator.cs @@ -8,12 +8,6 @@ public class GetUserProofDtoValidator : Validator { public GetUserProofDtoValidator() { - RuleFor(x => x.Id) - .NotEmpty() - .WithMessage("Id cannot be empty") - .GreaterThan(0) - .WithMessage("Id must be greater than 0"); - RuleFor(x => x.Proof) .NotEmpty() .WithMessage("Proof cannot be empty");