Ejemplo n.º 1
0
        public async Task <IActionResult> UploadShyneeAvatar(IFormFile image)
        {
            var id = Request.GetUserId();

            if (!image.IsImageExtensionAllowed())
            {
                return(new UnsupportedMediaTypeResult());
            }
            var uploadedImageName = await _assetsService.UploadImageAsync(
                _hostingEnvironment.WebRootPath,
                image);

            await _shyneesService.UpdateShyneeAvatarAsync(id, uploadedImageName);

            var uploadedAssetUri = new UploadedAssetPathDto(uploadedImageName);

            return(Ok(uploadedAssetUri));
        }
Ejemplo n.º 2
0
        public async Task <UploadedAssetPathDto> UpdateShyneeAvatarAsync(
            Guid shyneeId,
            string assetPath)
        {
            var shynee = await _shyneesRepository.GetShyneeAsync(shyneeId);

            var updatedShyneeProfile = new ShyneeProfile(
                shynee.Profile.Nickname.Parameter,
                assetPath,
                shynee.Profile.Name.Parameter,
                shynee.Profile.Dob.Parameter,
                shynee.Profile.Gender.Parameter,
                shynee.Profile.Interests.Parameter,
                shynee.Profile.PersonalInfo.Parameter);

            shynee.UpdateProfile(updatedShyneeProfile);
            await _shyneesRepository.UpdateShyneeAsync(shynee);

            var uploadedAssetUri = new UploadedAssetPathDto(
                shynee.Profile.AvatarUri.Parameter);

            return(uploadedAssetUri);
        }