From 8282f6c3f89ee65be155d453ddd705892b07628e Mon Sep 17 00:00:00 2001 From: transtrike Date: Sun, 28 Mar 2021 19:21:49 +0300 Subject: ProfilePic saved in User fixed --- src/Services/DevHive.Services/Services/ProfilePictureService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Services/DevHive.Services') 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 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); -- cgit v1.2.3