Website Summary Files Commits Branches @commit @diff @stats
path: root / src / DevHive.Data / Repositories / RatingRepository.cs
diff options
context:
space:
mode:
Commit75eeb4358e746d887677903052ed4bd5ca176f4d (patch)
Author
 transtrike <transtrike@gmail.com>
2021-02-05 19:00:24 +0200
Committer
 transtrike <transtrike@gmail.com>
2021-02-05 19:00:24 +0200
Files9f9b9eb0103d61f488c08fa4b4b5f308ca9ab35a /src/DevHive.Data/Repositories/RatingRepository.cs
DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.tar
DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.tar.gz
DevHive-75eeb4358e746d887677903052ed4bd5ca176f4d.zip
Parent51e157d1e1dc57ea2ba9c29b355fa7982a29bebe (diff)
Parent4eb5ccdfc8ee4ac9795c48c701e565dbe2b641f9 (diff)
Merge branch 'dev' of github.com:Team-Kaleidoscope/DevHive into dev
1 files changed, 8 insertions, 7 deletions
-rw-r--r--src/DevHive.Data/Repositories/RatingRepository.cs15
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);
}
}
}