public static async Task <string> SendReshardingValuesAsync(int key, string value) { string url = "http://localhost:10000/proxy/" + key.ToString(); string responseContent; ValueDTO data = new ValueDTO { Value = value }; string postBody = JsonConvert.SerializeObject(data); using (var client = new HttpClient()) { var response = await client.PutAsync(url, new StringContent(postBody, Encoding.UTF8, "application/json")); string content = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK) { responseContent = JsonConvert.DeserializeObject(content).ToString(); } else { responseContent = value; } return(responseContent); } }
public static async Task <string> PutValue(int id, string value) { string nodePort = Nodes.Ports[ProxyModel.GetShardNumber(id)]; string url = "http://localhost:" + nodePort + "/database/" + id.ToString(); string responseContent; ValueDTO data = new ValueDTO { Value = value }; string postBody = JsonConvert.SerializeObject(data); using (var client = new HttpClient()) { var response = await client.PutAsync(url, new StringContent(postBody, Encoding.UTF8, "application/json")); string content = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK) { responseContent = JsonConvert.DeserializeObject(content).ToString(); } else { responseContent = value; } return(responseContent); } }