Fixed error of mapping with proofs
This commit is contained in:
@@ -2,6 +2,5 @@
|
|||||||
|
|
||||||
public class GetUserProofDto
|
public class GetUserProofDto
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
public string? Proof { get; set; }
|
public string? Proof { get; set; }
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ using FastEndpoints;
|
|||||||
|
|
||||||
namespace BeReadyBackend.Endpoints.Users;
|
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()
|
public override void Configure()
|
||||||
{
|
{
|
||||||
@@ -31,12 +31,18 @@ public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserServi
|
|||||||
proofs.AddRange(
|
proofs.AddRange(
|
||||||
user.UserRandomChallenges
|
user.UserRandomChallenges
|
||||||
.Where(x => x.Proof is not null)
|
.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)
|
if (user.UserGroups is not null)
|
||||||
proofs.AddRange(
|
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);
|
await Send.OkAsync(proofs, ct);
|
||||||
|
|||||||
@@ -8,12 +8,6 @@ public class GetUserProofDtoValidator : Validator<GetUserProofDto>
|
|||||||
{
|
{
|
||||||
public GetUserProofDtoValidator()
|
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)
|
RuleFor(x => x.Proof)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.WithMessage("Proof cannot be empty");
|
.WithMessage("Proof cannot be empty");
|
||||||
|
|||||||
Reference in New Issue
Block a user