diff options
| author | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-02-03 21:05:47 +0200 |
|---|---|---|
| committer | Danail Dimitrov <danaildimitrov321@gmail.com> | 2021-02-03 21:05:47 +0200 |
| commit | 7e77ab4c7d96e853a40c313bf59bf2cb9d3735eb (patch) | |
| tree | a9c99cf1e3d69da9c329cfe20c368764645c3614 /src | |
| parent | a0d819bc3ad1f83c0bfa4294fc63679fb9d9f4d9 (diff) | |
| parent | 5446e356a9783645f5599fb2b4f7fe8f4d05e30e (diff) | |
| download | DevHive-7e77ab4c7d96e853a40c313bf59bf2cb9d3735eb.tar DevHive-7e77ab4c7d96e853a40c313bf59bf2cb9d3735eb.tar.gz DevHive-7e77ab4c7d96e853a40c313bf59bf2cb9d3735eb.zip | |
Merge branch 'dev' of https://github.com/Team-Kaleidoscope/DevHive into dev
Diffstat (limited to 'src')
| -rw-r--r-- | src/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs | 3 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/CommentRepository.cs | 11 | ||||
| -rw-r--r-- | src/DevHive.Services/Services/PostService.cs | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs b/src/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs index b80c5a0..267f251 100644 --- a/src/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs +++ b/src/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using DevHive.Data.Models; using DevHive.Data.Repositories.Interfaces; @@ -7,6 +8,8 @@ namespace DevHive.Data.Interfaces.Repositories { public interface ICommentRepository : IRepository<Comment> { + Task<List<Comment>> GetPostComments(Guid postId); + Task<bool> DoesCommentExist(Guid id); Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated); } diff --git a/src/DevHive.Data/Repositories/CommentRepository.cs b/src/DevHive.Data/Repositories/CommentRepository.cs index 1560c97..382c666 100644 --- a/src/DevHive.Data/Repositories/CommentRepository.cs +++ b/src/DevHive.Data/Repositories/CommentRepository.cs @@ -1,4 +1,7 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; using System.Threading.Tasks; using DevHive.Data.Interfaces.Repositories; using DevHive.Data.Models; @@ -31,6 +34,14 @@ namespace DevHive.Data.Repositories .FirstOrDefaultAsync(p => p.Creator.Id == issuerId && p.TimeCreated == timeCreated); } + + public async Task<List<Comment>> GetPostComments(Guid postId) + { + return await this._context.Posts + .SelectMany(x => x.Comments) + .Where(x => x.Post.Id == postId) + .ToListAsync(); + } #endregion #region Update diff --git a/src/DevHive.Services/Services/PostService.cs b/src/DevHive.Services/Services/PostService.cs index 8002468..6dbb272 100644 --- a/src/DevHive.Services/Services/PostService.cs +++ b/src/DevHive.Services/Services/PostService.cs @@ -105,6 +105,7 @@ namespace DevHive.Services.Services } post.Creator = await this._userRepository.GetByIdAsync(updatePostServiceModel.CreatorId); + post.Comments = await this._commentRepository.GetPostComments(updatePostServiceModel.PostId); post.TimeCreated = DateTime.Now; bool result = await this._postRepository.EditAsync(updatePostServiceModel.PostId, post); |
