Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            // var questionnaires = await context.Questionnaires.Include(q => q.Questions)
            //     .ToListAsync();
            var questionnaires = await questionnaireRepository.All();

            var vm = new QuestionnairesViewModel()
            {
                Questionnaires = questionnaires.Select(q =>
                {
                    return(new QuestionnaireViewModel()
                    {
                        Id = q.Id,
                        Title = q.Title,
                        FirstQuestionId = q.Questions.OrderBy(q => q.Id).First().Id
                    });
                }).ToList()
            };

            return(View(vm));
        }