aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services/Services/FeedService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Services/Services/FeedService.cs')
-rw-r--r--src/DevHive.Services/Services/FeedService.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/DevHive.Services/Services/FeedService.cs b/src/DevHive.Services/Services/FeedService.cs
index 269471e..ceb5ebf 100644
--- a/src/DevHive.Services/Services/FeedService.cs
+++ b/src/DevHive.Services/Services/FeedService.cs
@@ -54,5 +54,29 @@ namespace DevHive.Services.Services
return readPageServiceModel;
}
+
+ public async Task<ReadPageServiceModel> GetUserPage(GetPageServiceModel model) {
+ User user = null;
+
+ if (!string.IsNullOrEmpty(model.Username))
+ user = await this._userRepository.GetByUsernameAsync(model.Username);
+ else
+ throw new ArgumentException("Invalid given data!");
+
+ if (user == null)
+ throw new ArgumentException("User doesn't exist!");
+
+ List<Post> posts = await this._feedRepository
+ .GetUsersPosts(user, model.FirstRequestIssued, model.PageNumber, model.PageSize);
+
+ if (posts.Count <= 0)
+ throw new ArgumentException("User hasn't posted anything yet!");
+
+ ReadPageServiceModel readPageServiceModel = new();
+ foreach (Post post in posts)
+ readPageServiceModel.Posts.Add(this._mapper.Map<ReadPostServiceModel>(post));
+
+ return readPageServiceModel;
+ }
}
}