public IActionResult Index() { List <Child> posts = rd.GetPosts("aww"); return(View(posts)); }
public IActionResult TopTen(string subreddit) { TempData["sub"] = subreddit; SubRedditRoot srr = rdd.GetPosts(subreddit); if (srr.Error) { TempData["error"] = "When trying, the subreddit: " + subreddit + " something went horribly wrong"; return(RedirectToAction("Index")); } Child[] childrens = srr.data.children; List <Child> c = childrens.ToList(); if (c.Count == 1) { Child ch = c[0]; TempData["error"] = subreddit + " does not exist. Please try again."; } if (c.Count == 0) { TempData["error"] = subreddit + " does not exist. Please try again."; return(RedirectToAction("Index")); } return(View(c)); }
public ActionResult Reddit() { HttpWebRequest request = WebRequest.CreateHttp("https://www.reddit.com/r/nba/.json"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader rd = new StreamReader(response.GetResponseStream()); string data = rd.ReadToEnd(); List <RedditPost> output = RedditDAL.GetPosts(); return(View(output)); }