private async void ProcessRequest(IRequestAuthenticationMessage request) { Settings.IValues values = _settingsProvider.GetValues(); AuthenticationRequest authenticationRequest = new AuthenticationRequest { password = request.Password, email = request.EMail }; string serializedRequest = authenticationRequest.ToJson(); HttpContent content = new StringContent(serializedRequest, System.Text.Encoding.UTF8, "application/json"); HttpClient client = new HttpClient(); var response = await client.PostAsync(values.AuthenticationEndpoint, content); string result = await response.Content.ReadAsStringAsync(); AuthenticationResponse authenticationResponse = JsonSerializer.DeserializeFromString<AuthenticationResponse>(result); if (authenticationResponse.GetUserAuthTokenResult != null) { _messageMediator.Publish(new AuthenticationResponseMessage(authenticationResponse.GetUserAuthTokenResult.AccountId, authenticationResponse.GetUserAuthTokenResult.UserAuthToken)); } else { _messageMediator.Publish(new AuthenticationResponseMessage(authenticationResponse.ErrorCode, authenticationResponse.Message, authenticationResponse.Source)); } }
private async void ProcessRequest(IRequestAuthenticationMessage request) { Settings.IValues values = _settingsProvider.GetValues(); AuthenticationRequest authenticationRequest = new AuthenticationRequest { password = request.Password, email = request.EMail }; string serializedRequest = authenticationRequest.ToJson(); HttpContent content = new StringContent(serializedRequest, System.Text.Encoding.UTF8, "application/json"); HttpClient client = new HttpClient(); var response = await client.PostAsync(values.AuthenticationEndpoint, content); string result = await response.Content.ReadAsStringAsync(); AuthenticationResponse authenticationResponse = JsonSerializer.DeserializeFromString <AuthenticationResponse>(result); if (authenticationResponse.GetUserAuthTokenResult != null) { _messageMediator.Publish(new AuthenticationResponseMessage(authenticationResponse.GetUserAuthTokenResult.AccountId, authenticationResponse.GetUserAuthTokenResult.UserAuthToken)); } else { _messageMediator.Publish(new AuthenticationResponseMessage(authenticationResponse.ErrorCode, authenticationResponse.Message, authenticationResponse.Source)); } }