Exemplo n.º 1
0
        /// <summary>
        /// This view will be rendered if answer is in the URL string.
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> MyContent()
        {
            var culture     = this.Culture;
            var requestPath = this.RequestPathNoCulture;
            // Now try to parse the request path into known words.
            var commonStrings = _resourcesService.GetCommonStrings(culture);
            var answer        = LinkingHelper.ParseUrlToAnswer(commonStrings, requestPath);

            // Were we able to parse?
            if (answer == null)
            {
                return(RedirectToAction("Index"));
            }
            // Let's try to find that answer
            answer = await _answerService.FindExact(answer.LeftWord, answer.RightWord, answer.Phrase);

            // Go to home index if not found
            if (answer == null)
            {
                return(RedirectToAction("Index"));
            }
            // Get data
            var answerDetails = FillInDetails(answer, _answerDescriptionService, _userService, _voteService, _resourcesService,
                                              culture, _appSettings.Value.FullDomainAddress);

            // Do a bit more playing with data
            answerDetails.EnableFacebookSharing = _appSettings.Value.EnableFacebookSharing;

            answerDetails.DebugReactControls = ReadUrlParameterAsBoolean(DEBUG_REACTJS_URL_PARAMETER_NAME);

            return(View(answerDetails));
        }