From 379eda6a42fdba0a6ed7e7ae53e0fbf2acd774b6 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Fri, 26 Feb 2021 23:00:50 +0200 Subject: Adding update layer for rating_system --- src/Data/DevHive.Data/Repositories/RatingRepository.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Data/DevHive.Data/Repositories/RatingRepository.cs') diff --git a/src/Data/DevHive.Data/Repositories/RatingRepository.cs b/src/Data/DevHive.Data/Repositories/RatingRepository.cs index 02f92c0..9bb2368 100644 --- a/src/Data/DevHive.Data/Repositories/RatingRepository.cs +++ b/src/Data/DevHive.Data/Repositories/RatingRepository.cs @@ -32,19 +32,24 @@ namespace DevHive.Data.Repositories return await this._context.Rating .Where(x => x.Post.Id == postId).ToListAsync(); } - public async Task UserRatedPost(Guid userId, Guid postId) { - return await this._context.UserRate + return await this._context.Rating .Where(x => x.Post.Id == postId) .AnyAsync(x => x.User.Id == userId); } - public async Task GetRatingByUserAndPostId(Guid userId, Guid postId) { return await this._context.Rating .FirstOrDefaultAsync(x => x.Post.Id == postId && x.User.Id == userId); } + + public async Task DoesRatingExist(Guid id) + { + return await this._context.Rating + .AsNoTracking() + .AnyAsync(r => r.Id == id); + } } } -- cgit v1.2.3