public async Task SetThumbnailAsync(Guid eventId, Guid userId, byte[] thumbnail) { var @event = await TryGetEvent(eventId); if ([email protected](userId) && [email protected](userId)) { throw new ServiceException(ExceptionMessage.User.NoPermissionForOp); } if (!_imageProcessor.IsValidImage(thumbnail)) { throw new ServiceException(ExceptionMessage.File.InvalidInputFile); } thumbnail = await _imageProcessor.CreateThumbnailAsync(thumbnail); @event.SetThumbnail(thumbnail); await _eventRepository.UpdateAsync(@event); }
public async Task UpdateProfileImageAsync(Guid userId, byte[] imageData) { var user = await _userRepository.GetAsync(userId); CheckIfUserExists(user); if (!_imageProcessor.IsValidImage(imageData)) { throw new ServiceException(ExceptionMessage.File.InvalidInputFile); } imageData = await _imageProcessor.CreateThumbnailAsync(imageData); user.Profile.Image = new UserProfileImage { UserId = userId, BinaryData = imageData }; await _userRepository.UpdateAsync(user); }