public ActionResult Index(string q, string client, string client_version, string debug)
        {
            ViewBag.Title = "Natural Date and Time";
            if (!string.IsNullOrEmpty(q))
            {
                q = HttpUtility.UrlDecode(q);
                q = q.Replace("_", " ");
                ViewBag.Title = q + " -  Natural Date and Time";

                var answerService = new AnswerService();
                var answer = answerService.GetAnswer(q);

                var userAgent = String.Empty;
                if (Request.Headers["User-Agent"] != null)
                    userAgent = Request.Headers["User-Agent"].ToString();
                if (string.IsNullOrEmpty(client)) client = "web";
                if (string.IsNullOrEmpty(client_version)) client_version = "2.0";
                var dbContext = new NaturalDateTimeContext();
                var questionLog = new QuestionLog(answer.Question, answer, DateTime.UtcNow, client, client_version, IsBot(userAgent));
                dbContext.AddQuestionLog(questionLog);
                dbContext.SaveChanges();

                return View("Index", new HomeViewModel(q, answer.AnswerText, answer.Note));
            }

            return View(new HomeViewModel(!String.IsNullOrEmpty(debug)));
        }
 static void Main(string[] args)
 {
     ApplicationSettings.Initialise(System.Configuration.ConfigurationManager.AppSettings["PathToCityIndex"], String.Empty);
     System.Console.WriteLine();
     System.Console.Write("Enter the question: ");
     var userQuestion = System.Console.ReadLine();
     while (userQuestion != "exit")
     {
         System.Console.WriteLine();
         var answerService = new AnswerService();
         var answer = answerService.GetAnswer(userQuestion, true);
         foreach (var debugInformation in answer.DebugInformation)
             System.Console.WriteLine(String.Format("{0}: {1}", debugInformation.Name, debugInformation.Value));
         System.Console.WriteLine();
         System.Console.WriteLine("Answer: " + answer.AnswerText);
         System.Console.WriteLine();
         if (!String.IsNullOrEmpty(answer.Note))
         {
             System.Console.WriteLine("Note: " + answer.Note);
             System.Console.WriteLine();
         }
         System.Console.WriteLine();
         System.Console.Write("Enter the search term: ");
         userQuestion = System.Console.ReadLine();
     }
 }
        public ActionResult Question(string question, string client, string client_version, string debug)
        {
            if (string.IsNullOrEmpty(question)) throw new HttpException(400, "Invalid request. Question not specified.");
            if (string.IsNullOrEmpty(client)) throw new HttpException(400, "Invalid request. Client not specified.");
            if (string.IsNullOrEmpty(client_version)) throw new HttpException(400, "Invalid request. Client version not specified.");

            question = HttpUtility.UrlDecode(question);
            var userAgent = String.Empty;
            if (Request.Headers["User-Agent"] != null)
                userAgent = Request.Headers["User-Agent"].ToString();
            var answerService = new AnswerService();
            var answer = answerService.GetAnswer(question, !String.IsNullOrEmpty(debug));

            var dbContext = new NaturalDateTimeContext();
            var questionLog = new QuestionLog(answer.Question, answer, DateTime.UtcNow, client, client_version, IsBot(userAgent));
            dbContext.AddQuestionLog(questionLog);
            dbContext.SaveChanges();

            return Json(new AnswerModel(answer), JsonRequestBehavior.AllowGet);
        }