[HttpPost("GetReaderArticles")] //[HttpPost("GetReaderArticles/{topicOption}")] <- was giving issues public async Task <ActionResult> GetReaderArticles(ViewTopicModel model) { //System.Console.WriteLine("ViewTopicModel Name: " + model.Name); var topicOption = model.Name; var article = new List <ArticleViewModel>() { }; var response = await _http.GetAsync(apiUrl + "Article/GetArticleByTopic/" + topicOption); if (response.IsSuccessStatusCode) { var jsonResponse = await response.Content.ReadAsStringAsync(); var ArticleVMs = JsonConvert.DeserializeObject <List <ArticleViewModel> >(jsonResponse); var TopicVMs = JsonConvert.DeserializeObject <List <ViewTopicModel> >(TempData["TopicVMs"].ToString()); TempData["TopicVMs"] = JsonConvert.SerializeObject(TopicVMs); var ArticleTopicBundleVM = new ArticleTopicBundleViewModel(ArticleVMs, TopicVMs); ArticleTopicBundleVM.ChosenTopicToFilterBy = topicOption; return(await Task.FromResult(View("TopicSpecificArticles", ArticleTopicBundleVM))); } return(View("error")); }
public async Task <ActionResult> Get() { System.Console.WriteLine("ReaderArticles"); List <ViewTopicModel> Topics = null; bool TopicsWereReceived = false; List <ArticleViewModel> Articles = null; bool ArticlesWereReceived = false; var tResponse = await _http.GetAsync(apiUrl + "Topic/topics"); if (tResponse.IsSuccessStatusCode) { var JsonResponse = await tResponse.Content.ReadAsStringAsync(); var topicModel = JsonConvert.DeserializeObject <List <ViewTopicModel> >(JsonResponse); TempData["TopicVMs"] = JsonResponse; Topics = topicModel; TopicsWereReceived = true; System.Console.WriteLine(topicModel.Count); } var aResponse = await _http.GetAsync(apiUrl + "article/articles"); if (aResponse.IsSuccessStatusCode) { var jsonResponse = await aResponse.Content.ReadAsStringAsync(); var ObjOrderList = JsonConvert.DeserializeObject <List <ArticleViewModel> >(jsonResponse); var articles = ObjOrderList; Articles = articles; ArticlesWereReceived = true; } if (TopicsWereReceived && ArticlesWereReceived) { var ArticleTopicBundleVM = new ArticleTopicBundleViewModel(Articles, Topics); return(await Task.FromResult(View("ReaderMain", ArticleTopicBundleVM))); } return(View("error")); }