Exemplo n.º 1
0
        public StackOverflowSearchVM GetRecentGuesses()
        {
            StackOverflowSearchVM result = new StackOverflowSearchVM();

            try
            {
                using (CodingChallengeEntities data = new CodingChallengeEntities())
                {
                    var guesses = data.GuessLogs.GroupBy(g => g.QuestionID).Select(grp => grp.FirstOrDefault()).ToList();

                    result.items = new List <StackOverflowResultVM>();
                    foreach (var guess in guesses)
                    {
                        result.items.Add(new StackOverflowResultVM()
                        {
                            question_id   = guess.QuestionID,
                            title         = guess.QuestionText,
                            creation_date = guess.QuestionDate
                        });
                    }
                }
            }catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(result);
        }
Exemplo n.º 2
0
        public ActionResult Guesses()
        {
            GuessHandler handler = new GuessHandler();

            StackOverflowSearchVM searchResult = handler.GetRecentGuesses();

            return(View(searchResult));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            StackOverflowSearchVM searchResult = await CallStackOverflow <StackOverflowSearchVM>("search", "advanced", "order=desc&sort=creation&accepted=True&answers=2&site=stackoverflow");

            return(View(searchResult));
        }