public async Task <IActionResult> Profile(ProfileUpdateViewModel viewModel) { var user = _userService.GetCurrent(); if (viewModel.Avatar != null) { var path = _pathHelper.GetPathToAvatarByUser(user.Id); using (var fileStream = new FileStream(path, FileMode.OpenOrCreate)) { await viewModel.Avatar.CopyToAsync(fileStream); } user.AvatarUrl = _pathHelper.GetAvatarUrlByUser(user.Id); _logger.LogInformation($"User {user.Id} change avatar"); } user.Email = viewModel.Email; _userRepository.Save(user); return(RedirectToAction("Profile")); }