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 DateTime CreationDate { get; set; }
|
||||||
public int Likes { get; set; }
|
public int Likes { get; set; }
|
||||||
public bool IsLiked { get; set; }
|
public bool IsLiked { get; set; }
|
||||||
|
public string? Proof { get; set; }
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
public string? Username { get; set; }
|
public string? Username { get; set; }
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,10 @@ public class GetAllPostsEndpoint(PostsRepository postsRepository, UserService us
|
|||||||
Libelle = x.Libelle,
|
Libelle = x.Libelle,
|
||||||
CreationDate = x.CreationDate,
|
CreationDate = x.CreationDate,
|
||||||
Likes = x.Likes,
|
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,
|
UserId = x.UserId,
|
||||||
Username = x.User?.Username,
|
Username = x.User?.Username,
|
||||||
IsLiked = x.UserPosts?.Count(y => y.UserId == userId) > 0
|
IsLiked = x.UserPosts?.Count(y => y.UserId == userId) > 0
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ namespace BeReadyBackend.Endpoints.RandomChallenges;
|
|||||||
public class RandomChallengeProofRequest
|
public class RandomChallengeProofRequest
|
||||||
{
|
{
|
||||||
public int RandomChallengeId { get; set; }
|
public int RandomChallengeId { get; set; }
|
||||||
public string? Libelle { get; set; }
|
|
||||||
public IFormFile? Proof { get; set; }
|
public IFormFile? Proof { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,8 +84,8 @@ public class PatchProofEndpoint(
|
|||||||
|
|
||||||
Post post = new()
|
Post post = new()
|
||||||
{
|
{
|
||||||
Libelle = req.Libelle,
|
|
||||||
CreationDate = DateTime.Now,
|
CreationDate = DateTime.Now,
|
||||||
|
Libelle = "test pour le moment",
|
||||||
UserId = userId
|
UserId = userId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ public class GetPostNotMeSpec : Specification<Post>
|
|||||||
{
|
{
|
||||||
Query
|
Query
|
||||||
.Include(x => x.User)
|
.Include(x => x.User)
|
||||||
.Include(x => x.UserPosts!)
|
.ThenInclude(urc => urc.UserRandomChallenges)
|
||||||
|
.ThenInclude(r => r.RandomChallenge)
|
||||||
|
.Include(x => x.UserPosts)
|
||||||
.ThenInclude(up => up.User)
|
.ThenInclude(up => up.User)
|
||||||
.Where(x => x.UserId != userId &&
|
.Where(x => x.UserId != userId &&
|
||||||
x.CreationDate >= DateTime.Today && x.CreationDate < DateTime.Today.AddDays(1));
|
x.CreationDate >= DateTime.Today && x.CreationDate < DateTime.Today.AddDays(1));
|
||||||
|
|||||||
Reference in New Issue
Block a user