Exemple #1
0
        public async Task <IActionResult> ShowAnswer(string data = null)
        {
            // Data can't be null because at least answer id is there.
            var navigationData = NavigationHelper.Decode(data);

            if (navigationData == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var culture = this.Culture;
            // Load the answer.
            var answer = await _answerService.FindByAnswerId(navigationData.AnswerId);

            // Go home is not found
            if (answer == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var answerDetailsDto = HomeController.FillInDetails(answer, _answerDescriptionService, _userService, _voteService,
                                                                _resourcesService, culture, _appSettings.Value.FullDomainAddress);

            // Set the reason to be shown on the page in case someone sent it
            answerDetailsDto.Reason = navigationData.Reason;

            // Set the user leveling data in case we need to show level or achievement.
            answerDetailsDto.UserLevelingResult = navigationData.UserLevelingResult;

            return(View("MyContent", answerDetailsDto));
        }
Exemple #2
0
        public async Task <AdminAnswerViewModel> FillInTheAnswer(int answerId)
        {
            var answer = await _answerService.FindByAnswerId(answerId);

            // Load descriptions directly from database
            var descriptions = _answerDescriptionService.FindDirectByAnswerId(answerId);

            // Create the object for passing data between controllers.
            var navigationData = new NavigationDataDto();

            navigationData.AnswerId = answerId;

            var model = new AdminAnswerViewModel()
            {
                Answer             = answer,
                AnswerDescriptions = descriptions,
                NavigationData     = NavigationHelper.Encode(navigationData)
            };

            return(model);
        }