From 60ed435203f0c60d4c6fabe77aa4e87656aaf8c1 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Fri, 5 Feb 2021 16:36:47 +0200 Subject: Adding some metods to Rate repo --- src/DevHive.Data/Repositories/RatingRepository.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/DevHive.Data/Repositories') 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 GetByPostId(Guid postId) + public async Task 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 GetRating(Guid postId) + public async Task 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); } } } -- cgit v1.2.3