aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services/Services/PostService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DevHive.Services/Services/PostService.cs')
-rw-r--r--src/DevHive.Services/Services/PostService.cs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/DevHive.Services/Services/PostService.cs b/src/DevHive.Services/Services/PostService.cs
index 6e83ad4..f2f60d1 100644
--- a/src/DevHive.Services/Services/PostService.cs
+++ b/src/DevHive.Services/Services/PostService.cs
@@ -26,21 +26,35 @@ namespace DevHive.Services.Services
}
//Create
- public async Task<bool> CreatePost(CreatePostServiceModel postServiceModel)
+ public async Task<Guid> CreatePost(CreatePostServiceModel postServiceModel)
{
Post post = this._postMapper.Map<Post>(postServiceModel);
- return await this._postRepository.AddAsync(post);
+ bool success = await this._postRepository.AddAsync(post);
+
+ if(success)
+ {
+ Post newPost = await this._postRepository.GetPostByIssuerAndTimeCreatedAsync(postServiceModel.IssuerId, postServiceModel.TimeCreated);
+ return newPost.Id;
+ }
+ else
+ return Guid.Empty;
}
- public async Task<bool> AddComment(CreateCommentServiceModel commentServiceModel)
+ public async Task<Guid> AddComment(CreateCommentServiceModel commentServiceModel)
{
commentServiceModel.TimeCreated = DateTime.Now;
Comment comment = this._postMapper.Map<Comment>(commentServiceModel);
- bool result = await this._postRepository.AddCommentAsync(comment);
+ bool success = await this._postRepository.AddCommentAsync(comment);
- return result;
+ if(success)
+ {
+ Comment newComment = await this._postRepository.GetCommentByIssuerAndTimeCreatedAsync(commentServiceModel.IssuerId, commentServiceModel.TimeCreated);
+ return newComment.Id;
+ }
+ else
+ return Guid.Empty;
}
//Read