/// <summary> /// Default home page view. /// </summary> /// <returns></returns> // GET: /<controller>/ public IActionResult Index(string reason = null, string searchPhrase = null) { var model = new HomePageDto(); // Use the search service if search phrase is passed if (!string.IsNullOrEmpty(searchPhrase) && !string.IsNullOrWhiteSpace(searchPhrase)) { // store the phrase that user typed. _searchEntryService.AddSearchEntry(new SearchEntryDto { SearchPhrase = searchPhrase, UserId = GetUserId(User, _userService) }); model.TopToday.Answers = _answerService.FindLastAnswers(searchPhrase).ToList(); model.Keyword = searchPhrase; model.HeaderText = string.Format(_resourcesService.GetString(this.Culture, Lines.SEARCH_RESULTS_FOR), searchPhrase); model.IsSearch = true; } else { model.TopToday.Answers = _answerService.FindAnswersTrendingToday().ToList(); model.HeaderText = _resourcesService.GetString(this.Culture, Lines.TRENDING_TODAY); } // Answer service does not do any stiching. Meaning it can not set user information in the model/answers. // Need to add user info to answers Stitcher <AnswerDto> .Stitch(model.TopToday.Answers, _userService); model.Reason = reason; // Check if we need to debug react model.DebugReactControls = ReadUrlParameterAsBoolean(DEBUG_REACTJS_URL_PARAMETER_NAME); return(View(model)); }