diff --git a/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs b/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs index 8d1a0f2..56554e9 100644 --- a/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs +++ b/BeReadyBackend/Endpoints/RandomChallenges/PatchProofEndpoint.cs @@ -10,6 +10,7 @@ namespace BeReadyBackend.Endpoints.RandomChallenges; public class RandomChallengeProofRequest { public int RandomChallengeId { get; set; } + public string? Libelle { get; set; } public IFormFile? Proof { get; set; } } @@ -17,7 +18,8 @@ public class PatchProofEndpoint( UsersRepository usersRepository, UserRandomChallengesRepository userRandomChallengesRepository, UserService userService, - RandomChallengesRepository randomChallengesRepository) : Endpoint + RandomChallengesRepository randomChallengesRepository, + PostsRepository postsRepository) : Endpoint { public override void Configure() { @@ -80,6 +82,15 @@ public class PatchProofEndpoint( await usersRepository.SaveChangesAsync(ct); await userRandomChallengesRepository.SaveChangesAsync(ct); + + Post post = new() + { + Libelle = req.Libelle, + CreationDate = DateTime.Now, + UserId = userId + }; + + await postsRepository.AddAsync(post, ct); await Send.NoContentAsync(ct); } } \ No newline at end of file