diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-01-30 11:44:56 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-01-30 11:44:56 +0200 |
| commit | 19ef5e2cdbad996da58787c0fb22a35ab3dd59e8 (patch) | |
| tree | 74f5f4426b2ec369763f32e06bf63cd18995f8bf /src/DevHive.Data/Repositories/CommentRepository.cs | |
| parent | 8b164bf4ac8c307de933b476e858e489a64c0da5 (diff) | |
| download | DevHive-19ef5e2cdbad996da58787c0fb22a35ab3dd59e8.tar DevHive-19ef5e2cdbad996da58787c0fb22a35ab3dd59e8.tar.gz DevHive-19ef5e2cdbad996da58787c0fb22a35ab3dd59e8.zip | |
Fixed comment and post getting and updating
Diffstat (limited to 'src/DevHive.Data/Repositories/CommentRepository.cs')
| -rw-r--r-- | src/DevHive.Data/Repositories/CommentRepository.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/DevHive.Data/Repositories/CommentRepository.cs b/src/DevHive.Data/Repositories/CommentRepository.cs index d33b7bf..8ddc628 100644 --- a/src/DevHive.Data/Repositories/CommentRepository.cs +++ b/src/DevHive.Data/Repositories/CommentRepository.cs @@ -17,6 +17,14 @@ namespace DevHive.Data.Repositories } #region Read + public override async Task<Comment> GetByIdAsync(Guid id) + { + return await this._context.Comments + .Include(x => x.Creator) + .Include(x => x.Post) + .FirstOrDefaultAsync(x => x.Id == id); + } + public async Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated) { return await this._context.Comments @@ -25,6 +33,21 @@ namespace DevHive.Data.Repositories } #endregion + #region Update + public override async Task<bool> EditAsync(Guid id, Comment newEntity) + { + Comment comment = await this.GetByIdAsync(id); + + this._context + .Entry(comment) + .CurrentValues + .SetValues(newEntity); + + return await this.SaveChangesAsync(this._context); + } + #endregion + + #region Validations public async Task<bool> DoesCommentExist(Guid id) { |
