public async Task <IActionResult> UploadBase64Async([FromBody] ImageUploadBase64DTO imageBase64Dto) { var imgSrc = await _imageUploadService.UploadAsync(imageBase64Dto.Base64); var uploadedImageDto = new ImageDTO { Url = imgSrc }; return(Created(uploadedImageDto.Url, uploadedImageDto)); }
public async Task UpdateUserAvatar(ImageUploadBase64DTO imageUploadBase64DTO, int userId) { var imgSrc = await _imageUploader.UploadAsync(imageUploadBase64DTO.Base64); var userEntity = await _context.Users.SingleOrDefaultAsync(u => u.Id == userId); await _context.Images.AddAsync(new Image { Url = imgSrc }); await _context.SaveChangesAsync(); var imageId = await _context.Images.LastAsync(); userEntity.AvatarId = imageId.Id; _context.Users.Update(userEntity); await _context.SaveChangesAsync(); }
public async Task UpdateAvatar([FromBody] ImageUploadBase64DTO imageUploadBase64DTO) { var author = this.GetUserIdFromToken(); await _userService.UpdateUserAvatar(imageUploadBase64DTO, author); }