Пример #1
0
        public async Task <BaseOutput <object> > Post([FromBody] NewsInput input)
        {
            if (!ModelState.IsValid)
            {
                return(new BaseOutput <object>
                {
                    IsSuccessful = false,
                    Message = "Error",
                    Payload = "test"
                });
            }
            //get product from openfood
            var url         = $"{_appSettings.Service.Newspi}/top-headlines?country={input.Country}&apiKey={_appSettings.ApiKeys.HealthNews}&category=health";
            var getNewsInfo = await _webServiceInvoker.Get(url);

            var newsStr = await getNewsInfo.Content.ReadAsStringAsync();

            var saveNews = await _newsAppService.CreateNews(newsStr);

            return(saveNews);
        }