aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories/RatingRepository.cs
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-02-05 16:36:47 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-02-05 16:36:47 +0200
commit60ed435203f0c60d4c6fabe77aa4e87656aaf8c1 (patch)
treef20f5a64142612a5da582afee039b5d0f650776f /src/DevHive.Data/Repositories/RatingRepository.cs
parenta82c21a79772217fd22e4b9e2b36a655804186c8 (diff)
downloadDevHive-60ed435203f0c60d4c6fabe77aa4e87656aaf8c1.tar
DevHive-60ed435203f0c60d4c6fabe77aa4e87656aaf8c1.tar.gz
DevHive-60ed435203f0c60d4c6fabe77aa4e87656aaf8c1.zip
Adding some metods to Rate repo
Diffstat (limited to 'src/DevHive.Data/Repositories/RatingRepository.cs')
-rw-r--r--src/DevHive.Data/Repositories/RatingRepository.cs15
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);
}
}
}