コード例 #1
0
ファイル: ManagementController.cs プロジェクト: Burion/Admin
        private async Task <string> SaveAndGetLocalFilePathIfNewerPhoto(AddUserPicture model)
        {
            bool ValidateImage(AddUserPicture model) => model.ImageBytes != null && model.ImageType != null;

            var localFilePath =
                ValidateImage(model)
                ? await fileSavingService.SaveFileAsync(model.ImageBytes, model.ImageType, "images")
                : null;

            return(localFilePath);
        }
コード例 #2
0
ファイル: ManagementController.cs プロジェクト: Burion/Admin
        public async Task <Result> ChangeUserPicture(AddUserPicture model)
        {
            var localFilePath = await SaveAndGetLocalFilePathIfNewerPhoto(model);

            var user = await _userManager.FindByEmailAsync(User.Identity.Name);

            user.Image = localFilePath;
            await _userManager.UpdateAsync(user);

            return(new Result()
            {
                Successful = true
            });
        }