private async Task <ProfileVM> GetProfileVM(IUser user, ChangeProfileModel model = null, string errorMessage = null, string successMessage = null) { var externalProviders = await signInManager.GetExternalProvidersAsync(); var result = new ProfileVM { Id = user.Id, Email = user.Email, ErrorMessage = errorMessage, ExternalLogins = user.Logins, ExternalProviders = externalProviders, DisplayName = user.DisplayName(), IsHidden = user.IsHidden(), HasPassword = await userManager.HasPasswordAsync(user), HasPasswordAuth = identityOptions.Value.AllowPasswordAuth, SuccessMessage = successMessage }; if (model != null) { SimpleMapper.Map(model, result); } return(result); }
private async Task <ProfileVM> GetProfileVM(UserWithClaims user, ChangeProfileModel model = null, string errorMessage = null, string successMessage = null) { var taskForProviders = signInManager.GetExternalProvidersAsync(); var taskForPassword = userManager.HasPasswordAsync(user.Identity); var taskForLogins = userManager.GetLoginsAsync(user.Identity); await Task.WhenAll(taskForProviders, taskForPassword, taskForLogins); var result = new ProfileVM { Id = user.Id, Email = user.Email, ErrorMessage = errorMessage, ExternalLogins = taskForLogins.Result, ExternalProviders = taskForProviders.Result, DisplayName = user.DisplayName(), IsHidden = user.IsHidden(), HasPassword = taskForPassword.Result, HasPasswordAuth = identityOptions.Value.AllowPasswordAuth, SuccessMessage = successMessage }; if (model != null) { SimpleMapper.Map(model, result); } return(result); }