コード例 #1
0
        public virtual ActionResult IntervieweeDetails(int questionnaireId, int?ageId, int?sexId, int?educationId, int?martialStatusId,
                                                       int?materialStatusId, int?placeOfResidenceId, int?seniorityId, int?workplaceId)
        {
            var intervieweesIds = _intervieweesRepository.GetList(
                ageId: ageId,
                educationId: educationId,
                martialStatusId: martialStatusId,
                materialStatusId: materialStatusId,
                placeOfResidenceId: placeOfResidenceId,
                seniorityId: seniorityId,
                sexId: sexId,
                workplaceId: workplaceId)
                                  .Select(x => x.IntervieweeId)
                                  .ToList();

            var model = GetIntervieweeResultBasicViewModel(
                ageId: ageId,
                educationId: educationId,
                martialStatusId: martialStatusId,
                materialStatusId: materialStatusId,
                placeOfResidenceId: placeOfResidenceId,
                seniorityId: seniorityId,
                sexId: sexId,
                workplaceId: workplaceId);

            model.IntervieweeDetails = _resultsRepository.GetIntervieweeDetails(questionnaireId, intervieweesIds);
            model.Legend             = LegendViewModel.Details();

            ViewBag.QuestionnaireName = _questionnairesRepository.GetById(questionnaireId).Name;

            return(View(model));
        }
コード例 #2
0
        public virtual ActionResult Details(int questionnaireId)
        {
            var results = _resultsRepository.GetResultDetails(questionnaireId);

            var model = new ResultsListViewModel()
            {
                Title   = _questionnairesRepository.GetById(questionnaireId).Name,
                Results = new List <ResultsViewModel>(),
                Legend  = LegendViewModel.Details()
            };

            var questionsIds = results.Select(x => x.QuestionId).Distinct();

            foreach (var questionId in questionsIds)
            {
                var question = _questionsRepository.GetById(questionId);

                var questionResults = new ResultsViewModel()
                {
                    Id               = questionId,
                    Text             = $"{question.OrderNumber}. {question.Text}",
                    Options          = _answersRepository.GetDescriptions(questionId),
                    DictionaryGroups = new List <DictionaryGroupViewModel>()
                };

                var dictionaryGroupNames = results.Select(x => x.DictionaryTypeName).Distinct();
                foreach (var dictionaryType in dictionaryGroupNames)
                {
                    var dictionaryGroup = new DictionaryGroupViewModel()
                    {
                        GroupName       = dictionaryType,
                        DictionaryItems = new List <DictionaryItemViewModel>()
                    };

                    var dictionaryItemsIds = results.Where(x => x.DictionaryTypeName == dictionaryType).Select(x => x.BaseDictionaryId).Distinct();
                    foreach (var itemId in dictionaryItemsIds)
                    {
                        var dictionaryItem = new DictionaryItemViewModel()
                        {
                            ItemName = _dictionariesRepository.GetById(itemId).Value,
                            Badge    = results.First(x => x.BaseDictionaryId == itemId).IntervieweeCount.ToString(),
                            Values   = new List <ValueViewModel>()
                        };

                        var answersIdList = results.Where(x => x.QuestionId == questionId).Select(x => x.AnswerId).Distinct();
                        foreach (var answerId in answersIdList)
                        {
                            var resultItem = results
                                             .Where(x => x.QuestionId == questionId)
                                             .Where(x => x.BaseDictionaryId == itemId)
                                             .Where(x => x.AnswerId == answerId)
                                             .FirstOrDefault();

                            var value = new ValueViewModel()
                            {
                                Badge      = resultItem.AnswersCount.ToString(),
                                Count      = resultItem.AnswersCount,
                                TotalCount = resultItem.TotalAnswersCount
                            };
                            value.SetValueByPercentage();

                            dictionaryItem.Values.Add(value);
                        }

                        dictionaryGroup.DictionaryItems.Add(dictionaryItem);
                    }

                    questionResults.DictionaryGroups.Add(dictionaryGroup);
                }

                model.Results.Add(questionResults);
            }

            return(View(MVC.Application.Results.Views.Results, model));
        }