Example #1
0
        public async Task <string> AddProofImage()
        {
            var oneFileData = await FileUploadHelper.GetOneFileContent(Request);

            if (oneFileData.ErrorType == MultipartDataError.FileDataEmpty)
            {
                return("");// meaning url couldn't be retrieved. I don't want to throw exception and touch elmah.
            }
            return(await _imageService.SaveProofImage(oneFileData.FileData));
        }
Example #2
0
        public async Task <UrlResult> UploadAvatar()
        {
            var oneFileData = await FileUploadHelper.GetOneFileContent(Request);

            if (oneFileData.ErrorType == MultipartDataError.FileDataEmpty)
            {
                return(new UrlResult(OperationResultStatus.Error, "Avatar is empty"));
            }

            var avatarPath = await _imageService.SaveAvatarImage(this.GetCurrentUserId(), oneFileData.FileData);

            var result = await _userService.ChangeUserAvatar(this.GetCurrentUserId(), avatarPath);

            if (result.Status != OperationResultStatus.Success)
            {
                return(new UrlResult(result.Status, result.Description));
            }
            return(new UrlResult(avatarPath));
        }