예제 #1
0
        public IActionResult Index()
        {
            List <Child> posts = rd.GetPosts("aww");


            return(View(posts));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }