Ejemplo n.º 1
0
        public async Task <ViewResult> Index()
        {
            var questionnaire = await _service.GetQuestionnaireAsync();

            var viewModel = _mapper.Map <Questionnaire, QuestionnaireViewModel>(questionnaire);

            return(View(viewModel));
        }
        public async Task <FilledQuestionnaireResponse> GetAnsweredQuestionnaireAsync(string clientId)
        {
            var questionsTask = _questionnaireService.GetQuestionnaireAsync(clientId);
            var rankTask      = _questionnaireService.GetQuestionnaireRankAsync(clientId);

            await Task.WhenAll(questionsTask, rankTask);

            var result = new FilledQuestionnaireResponse
            {
                Questionnaire = _mapper.Map <AnsweredQuestionModel[]>(questionsTask.Result),
                Rank          = rankTask.Result?.Rank ?? 0
            };

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <ClientTierInfo> GetClientTierInfoAsync(string clientId, AccountTier clientTier, string country)
        {
            var currentTierTask   = GetCurrentTierAync(clientId, clientTier, country);
            var upgradeRequetTask = GetUpgradeRequestAsync(clientId, country);
            var questionnaireTask = _questionnaireService.GetQuestionnaireAsync(clientId);

            await Task.WhenAll(currentTierTask, upgradeRequetTask, questionnaireTask);

            NextTier nextTier = await GetNextTierAsync(clientId, clientTier, country, upgradeRequetTask.Result);


            var result = new ClientTierInfo
            {
                CurrentTier           = currentTierTask.Result,
                NextTier              = nextTier,
                UpgradeRequest        = upgradeRequetTask.Result,
                QuestionnaireAnswered = questionnaireTask.Result.Any()
            };

            return(result);
        }