예제 #1
0
        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"));
        }
예제 #2
0
        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());
        }