diff options
| author | transtrike <transtrike@gmail.com> | 2021-02-05 19:00:24 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-02-05 19:00:24 +0200 |
| commit | 75eeb4358e746d887677903052ed4bd5ca176f4d (patch) | |
| tree | 9f9b9eb0103d61f488c08fa4b4b5f308ca9ab35a /src/DevHive.Data/Repositories/RatingRepository.cs | |
| parent | 51e157d1e1dc57ea2ba9c29b355fa7982a29bebe (diff) | |
| parent | 4eb5ccdfc8ee4ac9795c48c701e565dbe2b641f9 (diff) | |
| download | DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.tar DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.tar.gz DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.zip | |
Merge branch 'dev' of github.com:Team-Kaleidoscope/DevHive into dev
Diffstat (limited to 'src/DevHive.Data/Repositories/RatingRepository.cs')
| -rw-r--r-- | src/DevHive.Data/Repositories/RatingRepository.cs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/DevHive.Data/Repositories/RatingRepository.cs b/src/DevHive.Data/Repositories/RatingRepository.cs index d676f27..1be8fe8 100644 --- a/src/DevHive.Data/Repositories/RatingRepository.cs +++ b/src/DevHive.Data/Repositories/RatingRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Threading.Tasks; using DevHive.Data.Interfaces.Repositories; using DevHive.Data.Models; @@ -18,17 +19,17 @@ namespace DevHive.Data.Repositories this._postRepository = postRepository; } - public async Task<Rating> GetByPostId(Guid postId) + public async Task<Rating> GetRatingByPostId(Guid postId) { - throw new NotImplementedException(); - // return await this._context.Rating - // .FirstOrDefaultAsync(x => x.Post.Id == postId); + return await this._context.Rating + .FirstOrDefaultAsync(x => x.Post.Id == postId); } - public async Task<int> GetRating(Guid postId) + public async Task<bool> UserRatedPost(Guid userId, Guid postId) { - throw new NotImplementedException(); - // return (await this.GetByPostId(postId)).Rate; + return await this._context.UserRate + .Where(x => x.Post.Id == postId) + .AnyAsync(x => x.User.Id == userId); } } } |
