public async Task <ProfileClientUser> ProfileClientUser(ProfileClientUserVM model) { ProfileClientUser res = null; try { var endpoint = _configuration.GetSection("API").GetSection("registerClientUser").Value; HttpClient client = _apiHelper.InitializeClient(); model.profileClientUser.password = _base64Helper.convertToBase64(model.profileClientUser.password); var json = JsonConvert.SerializeObject(model.profileClientUser); HttpContent registrationDetails = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(endpoint, registrationDetails); if (response.IsSuccessStatusCode) { res = JsonConvert.DeserializeObject <ProfileClientUser>(await response.Content.ReadAsStringAsync()); } else { res = JsonConvert.DeserializeObject <ProfileClientUser>(await response.Content.ReadAsStringAsync()); } } catch (Exception ex) { _logger.LogInformation($"{ex?.InnerException?.InnerException?.Message}"); } return(res); }
//public void AuthenticateUser() public async Task <LoginRegisteredUser> AuthenticateUser(Authenticate model) { LoginRegisteredUser res = null; try { string psdEncrypt = _encrypt.convertToBase64(model.password); model.password = psdEncrypt; var endpoint = _configuration.GetSection("API").GetSection("authenticate").Value; HttpClient client = _apiHelper.InitializeClient(); var json = JsonConvert.SerializeObject(model); HttpContent loginDetails = new StringContent(json, Encoding.UTF8, "application/json"); var response = await client.PostAsync(endpoint, loginDetails); if (response.IsSuccessStatusCode) { res = JsonConvert.DeserializeObject <LoginRegisteredUser>(await response.Content.ReadAsStringAsync()); } else { res = JsonConvert.DeserializeObject <LoginRegisteredUser>(await response.Content.ReadAsStringAsync()); } } catch (Exception ex) { _logger.LogInformation($"{ex?.InnerException?.InnerException?.Message}"); } return(res); }