Added proof on endpoint to see all posts

This commit is contained in:
2026-05-14 11:17:19 +01:00
parent 747ad10090
commit 01b7675703
4 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ public class GetPostDto
public DateTime CreationDate { get; set; }
public int Likes { get; set; }
public bool IsLiked { get; set; }
public string? Proof { get; set; }
public int UserId { get; set; }
public string? Username { get; set; }
}
@@ -26,6 +26,10 @@ public class GetAllPostsEndpoint(PostsRepository postsRepository, UserService us
Libelle = x.Libelle,
CreationDate = x.CreationDate,
Likes = x.Likes,
Proof = x.User?.UserRandomChallenges?
.SingleOrDefault(u =>
u.RandomChallenge?.GeneratedAt is not null && DateOnly.FromDateTime(u.RandomChallenge.GeneratedAt.Value) == DateOnly.FromDateTime(x.CreationDate))
?.Proof,
UserId = x.UserId,
Username = x.User?.Username,
IsLiked = x.UserPosts?.Count(y => y.UserId == userId) > 0
@@ -10,7 +10,6 @@ namespace BeReadyBackend.Endpoints.RandomChallenges;
public class RandomChallengeProofRequest
{
public int RandomChallengeId { get; set; }
public string? Libelle { get; set; }
public IFormFile? Proof { get; set; }
}
@@ -85,11 +84,11 @@ public class PatchProofEndpoint(
Post post = new()
{
Libelle = req.Libelle,
CreationDate = DateTime.Now,
Libelle = "test pour le moment",
UserId = userId
};
await postsRepository.AddAsync(post, ct);
await Send.NoContentAsync(ct);
}
@@ -9,7 +9,9 @@ public class GetPostNotMeSpec : Specification<Post>
{
Query
.Include(x => x.User)
.Include(x => x.UserPosts!)
.ThenInclude(urc => urc.UserRandomChallenges)
.ThenInclude(r => r.RandomChallenge)
.Include(x => x.UserPosts)
.ThenInclude(up => up.User)
.Where(x => x.UserId != userId &&
x.CreationDate >= DateTime.Today && x.CreationDate < DateTime.Today.AddDays(1));