refactor code of challenges and proofs in profil vue

This commit is contained in:
2026-05-14 11:38:41 +01:00
parent 01b7675703
commit f86fd80efc
3 changed files with 12 additions and 20 deletions
@@ -26,13 +26,10 @@ public class GetAllUserChallengesEndpoint(UsersRepository usersRepository, UserS
return;
}
List<GetUserChallengeDto> challenges = [];
if (user.UserRandomChallenges is not null)
challenges.AddRange(
user.UserRandomChallenges
.Where(x => x.Proof is not null)
.Select(x => mapper.Map<GetUserChallengeDto>(x.RandomChallenge))
);
List<GetUserChallengeDto> challenges = user.UserRandomChallenges?
.Where(x => x.Proof is not null)
.Select(x => mapper.Map<GetUserChallengeDto>(x.RandomChallenge))
.ToList() ?? [];
await Send.OkAsync(challenges.OrderByDescending(x => x.ChallengeStartDate).ToList(), ct);
}
@@ -25,17 +25,14 @@ public class GetAllUserProofsEndpoint(UsersRepository usersRepository, UserServi
await Send.NotFoundAsync(ct);
return;
}
List<GetUserProofDto> proofs = [];
if (user.UserRandomChallenges is not null)
proofs.AddRange(
user.UserRandomChallenges
.Where(x => x.Proof is not null)
.Select(x => new GetUserProofDto
{
Proof = x.Proof
})
);
List<GetUserProofDto> proofs = user.UserRandomChallenges?
.Where(x => x.Proof is not null)
.Select(x => new GetUserProofDto
{
Proof = x.Proof
})
.ToList() ?? [];
await Send.OkAsync(proofs, ct);
}
@@ -10,8 +10,6 @@ public class GetProofOrChallengeByUserIdSpec : SingleResultSpecification<User>
Query
.Include(x => x.UserRandomChallenges!)
.ThenInclude(x => x.RandomChallenge)
.Include(x => x.UserGroups!)
.ThenInclude(x => x.Group)
.Where(x => x.Id == userId);
}
}