public async Task <IActionResult> DeletePersonalDataNow() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } var result = await _userService.Delete(user.Id.ToString()); var userId = await _userManager.GetUserIdAsync(user); var id = await _steamIdentityService.FindOne(user.Id); if (id != null) { await _pavlovServerPlayerHistoryService.DeleteMany(id.Id); await _matchService.AnonymizeTheStats(id.Id); await _steamIdentityStatsServerService.DeleteForSteamId(id.Id); } if (id != null && id.OculusId != "" && await _steamIdentityService.FindOne(id.OculusId) == null) { await _pavlovServerPlayerHistoryService.DeleteMany(id.OculusId); await _matchService.AnonymizeTheStats(id.OculusId); await _steamIdentityStatsServerService.DeleteForSteamId(id.OculusId); } if (!result.Succeeded) { throw new InvalidOperationException($"Unexpected error occurred deleting user."); } await _signInManager.SignOutAsync(); _logger.LogInformation("User with ID '{UserId}' deleted themselves.", userId); return(Redirect("~/")); }