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 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/Data/DevHive.Data/Repositories') 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 -- cgit v1.2.3