예제 #1
0
        public string ValidateNewsAsync(NewsToClassify news)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://localhost:5003");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            var postTask = client.PostAsJsonAsync("api/v1/validator", news);

            postTask.Wait();

            var result = postTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsAsync <string>();
                readTask.Wait();

                var newsResult = readTask.Result;
                return(newsResult);
            }
            else
            {
                Console.WriteLine(result.StatusCode);
                return(null);
            }
        }
예제 #2
0
 public ActionResult <string> ValidateText([FromBody] NewsToClassify data)
 {
     return(Ok(_repository.ValidateNewsAsync(data)));
 }