public async Task <IActionResult> Post([FromBody] string value) { if (string.IsNullOrEmpty(value)) { return(BadRequest()); } Diagnosis diagnosis; try { diagnosis = JsonConvert.DeserializeObject <Diagnosis>(value); } catch (Exception) { return(BadRequest()); } DiagnosisData.Add(diagnosis); var predictions = EyesTrainer.PredictImage(diagnosis.Eye.Data.ToStream()); string contentResult; try { contentResult = JsonConvert.SerializeObject(predictions); } catch (Exception) { return(BadRequest()); } return(Content(contentResult, "application/json")); }
public IActionResult Put(int id, [FromBody] string value) { if (string.IsNullOrEmpty(value)) { return(BadRequest()); } Diagnosis diagnosis; try { diagnosis = JsonConvert.DeserializeObject <Diagnosis>(value); } catch (Exception) { return(BadRequest()); } DiagnosisData.Add(diagnosis); return(Ok()); }