diff options
Diffstat (limited to 'src/DevHive.Data')
| -rw-r--r-- | src/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs | 3 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/CommentRepository.cs | 11 |
2 files changed, 14 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 |
