Fixed error of mapping with proofs

This commit is contained in:
2026-04-16 15:55:13 +01:00
parent c054b9d88c
commit d048d78cb2
3 changed files with 10 additions and 11 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
namespace BeReadyBackend.DTO.Users;
public class GetUserProofDto
{
public int Id { get; set; }
{
public string? Proof { get; set; }
}
@@ -7,7 +7,7 @@ using FastEndpoints;
namespace BeReadyBackend.Endpoints.Users;
public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserService userService, AutoMapper.IMapper mapper) : EndpointWithoutRequest<List<GetUserProofDto>>
public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserService userService) : EndpointWithoutRequest<List<GetUserProofDto>>
{
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<GetUserProofDto>(x.RandomChallenge))
.Select(x => new GetUserProofDto
{
Proof = x.Proof
})
);
if (user.UserGroups is not null)
proofs.AddRange(
user.UserGroups.Select(x => mapper.Map<GetUserProofDto>(x.Group))
user.UserGroups.Select(x => new GetUserProofDto
{
Proof = x.Proof
})
);
await Send.OkAsync(proofs, ct);
@@ -8,12 +8,6 @@ public class GetUserProofDtoValidator : Validator<GetUserProofDto>
{
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");