Website Summary Files Commits Branches @commit @diff @stats
path: root / src / DevHive.Services / Services / PostService.cs
diff options
context:
space:
mode:
Commit83f63ad729d585d597bdcf0afc05b7d56344223e (patch)
Author
 transtrike <transtrike@gmail.com>
2021-01-17 13:38:24 +0200
Committer
 transtrike <transtrike@gmail.com>
2021-01-17 13:38:24 +0200
Filesede845ad2790fe6f6f975f3cc5d776782adecf59 /src/DevHive.Services/Services/PostService.cs
DevHive-83f63ad729d585d597bdcf0afc05b7d56344223e.tar
DevHive-83f63ad729d585d597bdcf0afc05b7d56344223e.tar.gz
DevHive-83f63ad729d585d597bdcf0afc05b7d56344223e.zip
Parentb4454f83c3b7d668fc8b18714a659b91576882be (diff)
Lang&Tech layers now return id on Create
1 files changed, 19 insertions, 5 deletions
-rw-r--r--src/DevHive.Services/Services/PostService.cs24
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