diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-01-30 13:07:54 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-01-30 13:07:54 +0200 |
| commit | 498af41f38b14372bd2f5eb9a0add7af95c40168 (patch) | |
| tree | 31c00985399ee352c1a09f4d650f62696e117350 /src/DevHive.Data | |
| parent | a8cc808396a24f0a5e4262d07e3edae1a4e5fc1d (diff) | |
| download | DevHive-498af41f38b14372bd2f5eb9a0add7af95c40168.tar DevHive-498af41f38b14372bd2f5eb9a0add7af95c40168.tar.gz DevHive-498af41f38b14372bd2f5eb9a0add7af95c40168.zip | |
Fixed GetUserPosts implementation
Diffstat (limited to 'src/DevHive.Data')
| -rw-r--r-- | src/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs | 1 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/FeedRepository.cs | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs b/src/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs index e9fd48a..7262510 100644 --- a/src/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs +++ b/src/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs @@ -8,5 +8,6 @@ namespace DevHive.Data.Interfaces.Repositories public interface IFeedRepository { Task<List<Post>> GetFriendsPosts(List<User> friendsList, DateTime firstRequestIssued, int pageNumber, int pageSize); + Task<List<Post>> GetUsersPosts(User user, DateTime firstRequestIssued, int pageNumber, int pageSize); } } diff --git a/src/DevHive.Data/Repositories/FeedRepository.cs b/src/DevHive.Data/Repositories/FeedRepository.cs index efcb8e0..7ab9a91 100644 --- a/src/DevHive.Data/Repositories/FeedRepository.cs +++ b/src/DevHive.Data/Repositories/FeedRepository.cs @@ -32,5 +32,18 @@ namespace DevHive.Data.Repositories return posts; } + + public async Task<List<Post>> GetUsersPosts(User user, DateTime firstRequestIssued, int pageNumber, int pageSize) + { + List<Post> posts = await this._context.Posts + .Where(post => post.TimeCreated < firstRequestIssued) + .Where(p => p.Creator.Id == user.Id) + .OrderByDescending(x => x.TimeCreated) + .Skip((pageNumber - 1) * pageSize) + .Take(pageSize) + .ToListAsync(); + + return posts; + } } } |
