Exemplo n.º 1
0
        public async Task <CreationResultDto <string> > UpdateProfilePicture(long userId, UserUpdateProfilePicture userUpdateProfilePhoto)
        {
            if (string.IsNullOrWhiteSpace(userUpdateProfilePhoto.ProfilePicture))
            {
                throw new UserException(UserError.ProfilePhotoIsEmpty);
            }

            var user = _dbContext.Users.FirstOrDefault(x => x.UserId == userId);

            if (user == null)
            {
                throw new UserException(UserError.DoesNotExist);
            }
            user.ProfilePicture = Guid.NewGuid();

            var profilePhoto = Convert.FromBase64String(userUpdateProfilePhoto.ProfilePicture);

            await _blobStorage.Upload(profilePhoto, $"{user.ProfilePicture}.png");

            _dbContext.SaveChanges();

            return(new CreationResultDto <string>
            {
                Id = _applicationConfiguration.GetProfilePictureUrl(user.ProfilePicture)
            });
        }
Exemplo n.º 2
0
 public async Task <CreationResultDto <string> > UpdateProfilePicture(UserUpdateProfilePicture userUpdateProfilePicture)
 {
     return(await _userBusiness.UpdateProfilePicture(UserId, userUpdateProfilePicture));
 }