aboutsummaryrefslogtreecommitdiff
path: root/src/Services/DevHive.Services
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-03-28 19:16:15 +0300
committertranstrike <transtrike@gmail.com>2021-03-28 19:16:15 +0300
commita789a23c3c8ddde8188f2da40402a1803f838f89 (patch)
treedaff292b6562a7f49cc2900e249a77243b8919e9 /src/Services/DevHive.Services
parent4f6d554f95afac9c4eb7358596e4a7ce3aeb5a30 (diff)
parent15904cb3d2ef9442b682322353c378ab321520e5 (diff)
downloadDevHive-a789a23c3c8ddde8188f2da40402a1803f838f89.tar
DevHive-a789a23c3c8ddde8188f2da40402a1803f838f89.tar.gz
DevHive-a789a23c3c8ddde8188f2da40402a1803f838f89.zip
Dev changes merged into ProfilePicLayer branch
Diffstat (limited to 'src/Services/DevHive.Services')
-rw-r--r--src/Services/DevHive.Services/Services/ProfilePictureService.cs5
-rw-r--r--src/Services/DevHive.Services/Services/RatingService.cs10
2 files changed, 9 insertions, 6 deletions
diff --git a/src/Services/DevHive.Services/Services/ProfilePictureService.cs b/src/Services/DevHive.Services/Services/ProfilePictureService.cs
index 8a9bb29..7093818 100644
--- a/src/Services/DevHive.Services/Services/ProfilePictureService.cs
+++ b/src/Services/DevHive.Services/Services/ProfilePictureService.cs
@@ -41,7 +41,7 @@ namespace DevHive.Services.Services
await ValidateUserExistsAsync(profilePictureServiceModel.UserId);
User user = await this._userRepository.GetByIdAsync(profilePictureServiceModel.UserId);
- if (!string.IsNullOrEmpty(user.ProfilePicture.PictureURL))
+ if (user.ProfilePicture.Id != Guid.Empty)
{
List<string> file = new() { user.ProfilePicture.PictureURL };
bool removed = await this._cloudinaryService.RemoveFilesFromCloud(file);
@@ -81,8 +81,9 @@ namespace DevHive.Services.Services
throw new ArgumentException("Unable to upload picture!");
User user = await this._userRepository.GetByIdAsync(profilePictureServiceModel.UserId);
- user.ProfilePicture = await this._profilePictureRepository.GetByURLAsync(picUrl);
+ user.ProfilePicture = profilePic;
bool userProfilePicAlter = await this._userRepository.EditAsync(user.Id, user);
+
if (!userProfilePicAlter)
throw new ArgumentException("Unable to alter user's profile picture");
diff --git a/src/Services/DevHive.Services/Services/RatingService.cs b/src/Services/DevHive.Services/Services/RatingService.cs
index 1f77a6e..9d8f4b0 100644
--- a/src/Services/DevHive.Services/Services/RatingService.cs
+++ b/src/Services/DevHive.Services/Services/RatingService.cs
@@ -57,8 +57,9 @@ namespace DevHive.Services.Services
#region Read
public async Task<ReadRatingServiceModel> GetRatingById(Guid ratingId)
{
- Rating rating = await this._ratingRepository.GetByIdAsync(ratingId) ??
- throw new ArgumentException("The rating does not exist");
+ Rating rating = await this._ratingRepository.GetByIdAsync(ratingId);
+ if (rating is null)
+ return null;
ReadRatingServiceModel readRatingServiceModel = this._mapper.Map<ReadRatingServiceModel>(rating);
readRatingServiceModel.UserId = rating.User.Id;
@@ -68,8 +69,9 @@ namespace DevHive.Services.Services
public async Task<ReadRatingServiceModel> GetRatingByPostAndUser(Guid userId, Guid postId)
{
- Rating rating = await this._ratingRepository.GetRatingByUserAndPostId(userId, postId) ??
- throw new ArgumentException("The rating does not exist");
+ Rating rating = await this._ratingRepository.GetRatingByUserAndPostId(userId, postId);
+ if (rating is null)
+ return null;
ReadRatingServiceModel readRatingServiceModel = this._mapper.Map<ReadRatingServiceModel>(rating);
readRatingServiceModel.UserId = rating.User.Id;