diff options
| author | transtrike <transtrike@gmail.com> | 2021-04-07 18:41:30 +0300 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-04-07 18:41:30 +0300 |
| commit | b8d1edfc582bee2ef648757bcad1bbadd075bb08 (patch) | |
| tree | 0042a44c3091af36994cdc9b91a835ed1d803eaa /src/Data/DevHive.Data/Repositories | |
| parent | f4eac9c89bef0c21d7ccb29cb0841fa621c79f46 (diff) | |
| parent | da7d6223c261aac8e8f18458c11fb48cf9ca4cfe (diff) | |
| download | DevHive-b8d1edfc582bee2ef648757bcad1bbadd075bb08.tar DevHive-b8d1edfc582bee2ef648757bcad1bbadd075bb08.tar.gz DevHive-b8d1edfc582bee2ef648757bcad1bbadd075bb08.zip | |
Merged from dev
Diffstat (limited to 'src/Data/DevHive.Data/Repositories')
3 files changed, 29 insertions, 9 deletions
diff --git a/src/Data/DevHive.Data/Repositories/PostRepository.cs b/src/Data/DevHive.Data/Repositories/PostRepository.cs index 0a88cf2..b5228c2 100644 --- a/src/Data/DevHive.Data/Repositories/PostRepository.cs +++ b/src/Data/DevHive.Data/Repositories/PostRepository.cs @@ -60,7 +60,6 @@ namespace DevHive.Data.Repositories public override async Task<bool> EditAsync(Guid id, Post newEntity) { Post post = await this.GetByIdAsync(id); - // var ratingId = post.Rating.Id; this._context .Entry(post) @@ -76,8 +75,6 @@ namespace DevHive.Data.Repositories foreach (var comment in newEntity.Comments) post.Comments.Add(comment); - // post.Rating.Id = ratingId; - this._context.Entry(post).State = EntityState.Modified; return await this.SaveChangesAsync(); diff --git a/src/Data/DevHive.Data/Repositories/ProfilePictureRepository.cs b/src/Data/DevHive.Data/Repositories/ProfilePictureRepository.cs new file mode 100644 index 0000000..7284464 --- /dev/null +++ b/src/Data/DevHive.Data/Repositories/ProfilePictureRepository.cs @@ -0,0 +1,25 @@ +using System.Threading.Tasks; +using DevHive.Data.Interfaces; +using DevHive.Data.Models; +using Microsoft.EntityFrameworkCore; + +namespace DevHive.Data.Repositories +{ + public class ProfilePictureRepository : BaseRepository<ProfilePicture>, IProfilePictureRepository + { + private readonly DevHiveContext _context; + + public ProfilePictureRepository(DevHiveContext context) + : base(context) + { + this._context = context; + } + + public async Task<ProfilePicture> GetByURLAsync(string picUrl) + { + return await this._context + .ProfilePicture + .FirstOrDefaultAsync(x => x.PictureURL == picUrl); + } + } +} diff --git a/src/Data/DevHive.Data/Repositories/RatingRepository.cs b/src/Data/DevHive.Data/Repositories/RatingRepository.cs index c35f6d5..2048c3f 100644 --- a/src/Data/DevHive.Data/Repositories/RatingRepository.cs +++ b/src/Data/DevHive.Data/Repositories/RatingRepository.cs @@ -11,13 +11,11 @@ namespace DevHive.Data.Repositories public class RatingRepository : BaseRepository<Rating>, IRatingRepository { private readonly DevHiveContext _context; - private readonly IPostRepository _postRepository; - public RatingRepository(DevHiveContext context, IPostRepository postRepository) + public RatingRepository(DevHiveContext context) : base(context) { this._context = context; - this._postRepository = postRepository; } public override async Task<Rating> GetByIdAsync(Guid id) @@ -28,7 +26,7 @@ namespace DevHive.Data.Repositories .FirstOrDefaultAsync(x => x.Id == id); } /// <summary> - /// Gets all the ratings for a psot. + /// Gets all the ratings for a post. /// </summary> /// <param name="postId">Id of the post.</param> /// <returns></returns> @@ -40,10 +38,10 @@ namespace DevHive.Data.Repositories .Where(x => x.Post.Id == postId).ToListAsync(); } /// <summary> - /// Checks if a user rated a given post. In DevHive every user has one or no rating for every post. + /// Checks if a user rated a given post. In DevHive every user has one or no rating for every post. /// </summary> /// <param name="userId">Id of the user.</param> - /// <param name="postId">Id of the psot.</param> + /// <param name="postId">Id of the post.</param> /// <returns>True if the user has already rated the post and false if he hasn't.</returns> public async Task<bool> UserRatedPost(Guid userId, Guid postId) { |
