public async Task <(bool, ModelStateDictionary)> UpdateAsync(PlayerUpdReqM playerUpdReqM, ModelStateDictionary modelStateDictionary) { string playerUpdReqMAsString = JsonConvert.SerializeObject(playerUpdReqM); StringContent stringContent = new StringContent(playerUpdReqMAsString, Encoding.UTF8, "application/json"); (string updateResp, string errorMessage) = await httpClientManager.PutAsync <string>(endpointOptions?.Value.Endpoint, stringContent); if (!string.IsNullOrEmpty(errorMessage)) { modelStateDictionary.AddModelError("Player", _Failed_ToUpdatePlayer); } return(string.IsNullOrEmpty(updateResp), modelStateDictionary); }
public async Task <UserRoleDTO> Update(UserRoleDTO user) { string url = _config["App:IdentityServerAddress"] + "api/users/"; var content = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json"); HttpResponseMessage response = await _client.PutAsync(new Uri( url), content); if (response.IsSuccessStatusCode) { using (HttpContent result = response.Content) { string responseBody = await response.Content.ReadAsStringAsync(); var createdUser = JsonConvert.DeserializeObject <UserRoleDTO>(responseBody); return(createdUser); } } else { var result = response.Content.ReadAsStringAsync().Result; throw new UserFriendlyException(result); } }