From 5c1216e864004c5694b3475b45e4047c2617a2d2 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 2 Feb 2021 09:06:16 +0200 Subject: Fixed comment order when getting a post --- src/DevHive.Services/Services/PostService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/DevHive.Services/Services/PostService.cs b/src/DevHive.Services/Services/PostService.cs index 3206479..8002468 100644 --- a/src/DevHive.Services/Services/PostService.cs +++ b/src/DevHive.Services/Services/PostService.cs @@ -65,6 +65,11 @@ namespace DevHive.Services.Services Post post = await this._postRepository.GetByIdAsync(id) ?? throw new ArgumentException("The post does not exist!"); + // This can't happen in repo, because of how time is usually compared + post.Comments = post.Comments + .OrderByDescending(x => x.TimeCreated.ToFileTimeUtc()) + .ToList(); + User user = await this._userRepository.GetByIdAsync(post.Creator.Id) ?? throw new ArgumentException("The user does not exist!"); -- cgit v1.2.3