From e68181d5452f8e2c553c1eb36e689bab1ae080e3 Mon Sep 17 00:00:00 2001 From: Danail Dimitrov Date: Sun, 14 Mar 2021 21:16:53 +0200 Subject: added documentaion for rating repository --- .../DevHive.Data/Repositories/RatingRepository.cs | 22 ++++++++++++++++++++++ src/Web/DevHive.Web/Startup.cs | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Data/DevHive.Data/Repositories/RatingRepository.cs b/src/Data/DevHive.Data/Repositories/RatingRepository.cs index 1784144..e4a5d5d 100644 --- a/src/Data/DevHive.Data/Repositories/RatingRepository.cs +++ b/src/Data/DevHive.Data/Repositories/RatingRepository.cs @@ -27,6 +27,11 @@ namespace DevHive.Data.Repositories .Include(x => x.Post) .FirstOrDefaultAsync(x => x.Id == id); } + /// + /// Gets all the ratings for a psot. + /// + /// Id of the post. + /// public async Task> GetRatingsByPostId(Guid postId) { return await this._context.Rating @@ -34,12 +39,24 @@ namespace DevHive.Data.Repositories .Include(x => x.Post) .Where(x => x.Post.Id == postId).ToListAsync(); } + /// + /// Checks if a user rated a given post. + /// + /// Id of the user. + /// Id of the psot. + /// True if the user has already rated the post and false if he hasn't. public async Task UserRatedPost(Guid userId, Guid postId) { return await this._context.Rating .Where(x => x.Post.Id == postId) .AnyAsync(x => x.User.Id == userId); } + /// + /// Gets a rating by the post to which the rating corresponds and the user who created it. + /// + /// Id of the user. + /// Id of the post. + /// Rating for the given post by the given user. public async Task GetRatingByUserAndPostId(Guid userId, Guid postId) { return await this._context.Rating @@ -48,6 +65,11 @@ namespace DevHive.Data.Repositories .FirstOrDefaultAsync(x => x.Post.Id == postId && x.User.Id == userId); } + /// + /// Checks if a given rating already exist + /// + /// Id of the rating + /// True if the rating exists and false if it does not. public async Task DoesRatingExist(Guid id) { return await this._context.Rating diff --git a/src/Web/DevHive.Web/Startup.cs b/src/Web/DevHive.Web/Startup.cs index 40f674d..1c714ec 100644 --- a/src/Web/DevHive.Web/Startup.cs +++ b/src/Web/DevHive.Web/Startup.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using DevHive.Web.Configurations.Extensions; using Newtonsoft.Json; -using System.Threading.Tasks; namespace DevHive.Web { -- cgit v1.2.3