Added proof on endpoint to see all posts
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user