aboutsummaryrefslogtreecommitdiff
path: root/src/Services/DevHive.Services
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-03-28 19:21:49 +0300
committertranstrike <transtrike@gmail.com>2021-03-28 19:21:49 +0300
commit8282f6c3f89ee65be155d453ddd705892b07628e (patch)
tree822ce9d4043e2560234b21da568f685272cf722a /src/Services/DevHive.Services
parenta789a23c3c8ddde8188f2da40402a1803f838f89 (diff)
downloadDevHive-8282f6c3f89ee65be155d453ddd705892b07628e.tar
DevHive-8282f6c3f89ee65be155d453ddd705892b07628e.tar.gz
DevHive-8282f6c3f89ee65be155d453ddd705892b07628e.zip
ProfilePic saved in User fixed
Diffstat (limited to 'src/Services/DevHive.Services')
-rw-r--r--src/Services/DevHive.Services/Services/ProfilePictureService.cs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Services/DevHive.Services/Services/ProfilePictureService.cs b/src/Services/DevHive.Services/Services/ProfilePictureService.cs
index 7093818..0a4c824 100644
--- a/src/Services/DevHive.Services/Services/ProfilePictureService.cs
+++ b/src/Services/DevHive.Services/Services/ProfilePictureService.cs
@@ -41,6 +41,7 @@ namespace DevHive.Services.Services
await ValidateUserExistsAsync(profilePictureServiceModel.UserId);
User user = await this._userRepository.GetByIdAsync(profilePictureServiceModel.UserId);
+ // if (user.ProfilePicture.PictureURL != ProfilePicture.DefaultURL)
if (user.ProfilePicture.Id != Guid.Empty)
{
List<string> file = new() { user.ProfilePicture.PictureURL };
@@ -76,11 +77,14 @@ namespace DevHive.Services.Services
string picUrl = (await this._cloudinaryService.UploadFilesToCloud(file))[0];
ProfilePicture profilePic = new() { PictureURL = picUrl };
+ User user = await this._userRepository.GetByIdAsync(profilePictureServiceModel.UserId);
+ profilePic.UserId = user.Id;
+ profilePic.User = user;
+
bool success = await this._profilePictureRepository.AddAsync(profilePic);
if (!success)
throw new ArgumentException("Unable to upload picture!");
- User user = await this._userRepository.GetByIdAsync(profilePictureServiceModel.UserId);
user.ProfilePicture = profilePic;
bool userProfilePicAlter = await this._userRepository.EditAsync(user.Id, user);