diff options
| author | transtrike <transtrike@gmail.com> | 2021-01-17 13:38:24 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-01-17 13:38:24 +0200 |
| commit | 83f63ad729d585d597bdcf0afc05b7d56344223e (patch) | |
| tree | ede845ad2790fe6f6f975f3cc5d776782adecf59 /src/DevHive.Services/Services/PostService.cs | |
| parent | b4454f83c3b7d668fc8b18714a659b91576882be (diff) | |
| download | DevHive-83f63ad729d585d597bdcf0afc05b7d56344223e.tar DevHive-83f63ad729d585d597bdcf0afc05b7d56344223e.tar.gz DevHive-83f63ad729d585d597bdcf0afc05b7d56344223e.zip | |
Lang&Tech layers now return id on Create
Diffstat (limited to 'src/DevHive.Services/Services/PostService.cs')
| -rw-r--r-- | src/DevHive.Services/Services/PostService.cs | 24 |
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 |
