diff options
| author | transtrike <transtrike@gmail.com> | 2021-01-23 22:34:43 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-01-23 22:34:43 +0200 |
| commit | e01a81954e0fba2c4521e03a76f48a970a87994f (patch) | |
| tree | d2fdacbed68de0f4f32b1d949d75bc1de9f861d3 /src/DevHive.Data/Repositories/CommentRepository.cs | |
| parent | fac1bf2d1772e60cbecc1cf0381c6063a0e97ffd (diff) | |
| download | DevHive-e01a81954e0fba2c4521e03a76f48a970a87994f.tar DevHive-e01a81954e0fba2c4521e03a76f48a970a87994f.tar.gz DevHive-e01a81954e0fba2c4521e03a76f48a970a87994f.zip | |
All Post&Comment Implemented; Initializing testing...
Diffstat (limited to 'src/DevHive.Data/Repositories/CommentRepository.cs')
| -rw-r--r-- | src/DevHive.Data/Repositories/CommentRepository.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/DevHive.Data/Repositories/CommentRepository.cs b/src/DevHive.Data/Repositories/CommentRepository.cs new file mode 100644 index 0000000..880631a --- /dev/null +++ b/src/DevHive.Data/Repositories/CommentRepository.cs @@ -0,0 +1,37 @@ +using System; +using System.Threading.Tasks; +using DevHive.Data.Interfaces.Repositories; +using DevHive.Data.Models; +using Microsoft.EntityFrameworkCore; + +namespace DevHive.Data.Repositories +{ + public class CommentRepository : BaseRepository<Comment>, ICommentRepository + { + private readonly DevHiveContext _context; + + public CommentRepository(DevHiveContext context) + : base(context) + { + this._context = context; + } + + #region Read + public async Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated) + { + return await this._context.Comments + .FirstOrDefaultAsync(p => p.IssuerId == issuerId && + p.TimeCreated == timeCreated); + } + #endregion + + #region Validations + public async Task<bool> DoesCommentExist(Guid id) + { + return await this._context.Comments + .AsNoTracking() + .AnyAsync(r => r.Id == id); + } + #endregion + } +} |
