public async Task <IActionResult> NewRecord([FromBody] FitnessRecord newRecord) { if (await _dataStore.WriteRecord(newRecord)) { return(Ok("new record successfully written")); } return(StatusCode(400)); }
public async Task <bool> WriteRecord(FitnessRecord newRecord) { var client = _httpFactory.CreateClient("WRITER"); HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, "/api/fitness-data"); var requestJson = JsonConvert.SerializeObject(newRecord); message.Content = new StringContent(requestJson, Encoding.UTF8, "application/json"); var response = await client.SendAsync(message); return(response.IsSuccessStatusCode); }