public async Task <IActionResult> SendChangeEmail(int id, UserToChangeEmailDto userToChangeEmailDto) { var user = await accountManager.GetUser(id); if (await authService.GetUserByEmail(userToChangeEmailDto.Email) != null) { return(BadRequest("Użytkownik o takim adresie email już istnieje")); } var callbackUrl = await accountManager.GenerateEmailConfirmationCallbackUrl(user, userToChangeEmailDto.Email); if (await emailSender.SendEmail(StaticExpressions.ChangeEmailEmail(userToChangeEmailDto.Email, user.UserName, callbackUrl))) { return(Accepted()); } throw new AccountException("Wystąpił błąd podczas zmiany adresu email"); }