public IActionResult Reddit()
        {
            RedditModel reddit = new RedditModel();

            reddit = redditDAL.ConvertJsonToRedditModel();
            return(View(reddit));
        }
Example #2
0
        public async Task <List <RedditModel> > SearchReddit(string search)
        {
            var redditList     = new List <RedditModel>();
            var redditResponse = await _redditClient.GetRedditSearchInfo(search);

            foreach (var post in redditResponse.data.children)
            {
                var tempObject = new RedditModel();
                tempObject.Title      = post.data.title;
                tempObject.SubReddit  = post.data.subreddit;
                tempObject.AuthorName = post.data.author;
                tempObject.PermaLink  = "https://www.reddit.com" + post.data.permalink;
                tempObject.Downs      = post.data.downs;
                tempObject.Ups        = post.data.ups;
                redditList.Add(tempObject);
            }
            return(redditList);
        }
        public async Task <List <RedditModel> > SearchReddit(string search)
        {
            var redditList     = new List <RedditModel>();
            var redditResponse = await _redditClient.GetRedditSearchInfo(search);

            TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");

            foreach (var post in redditResponse.data.children)
            {
                var tempObject = new RedditModel();
                tempObject.Title      = post.data.title;
                tempObject.SubReddit  = post.data.subreddit;
                tempObject.AuthorName = post.data.author;
                tempObject.PermaLink  = "https://www.reddit.com" + post.data.permalink;
                redditList.Add(tempObject);
            }
            return(redditList);
        }
Example #4
0
        public IActionResult Reddit()
        {
            RedditModel reddit = new RedditModel();

            reddit = redditDAL.ConvertDataToRedditModel("aww");

            List <RedditPostViewModel> redditPosts = new List <RedditPostViewModel>();

            foreach (var item in reddit.data.children)
            {
                RedditPostViewModel singlePost = new RedditPostViewModel()
                {
                    subredditName = item.data.subreddit_name_prefixed,
                    Title         = item.data.title,
                    thumbUrl      = item.data.thumbnail,
                    url           = item.data.url,
                    dateCreated   = DateTimeOffset.FromUnixTimeSeconds((long)item.data.created_utc).ToLocalTime()
                };

                redditPosts.Add(singlePost);
            }

            return(View(redditPosts.Take(10).ToList()));
        }