Exemplo n.º 1
0
        public IActionResult ResultOverview(int id, [FromServices] IPlatformManager platformManager)
        {
            string   tenant   = HttpContext.Request.Host.Host.Split(".")[0];
            Platform platform = platformManager.GetPlatformByTenantWithForms(tenant);

            if (platform == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }
            List <Project> projects = platform.Projects;

            List <FormProjectsViewModel> projectsVm = new List <FormProjectsViewModel>();

            foreach (var project in projects)
            {
                List <Form> forms = project.Phases.SelectMany(p => p.Forms).ToList();

                FormProjectsViewModel vm = new FormProjectsViewModel()
                {
                    ProjectId = project.ProjectId,
                    Title     = project.Title
                };

                foreach (var form in forms)
                {
                    FormResultsViewModel formVm = new FormResultsViewModel()
                    {
                        FormId      = form.FormId,
                        Title       = form.Title,
                        AnswerCount = _formManager.GetFormReplyCount(form.FormId)
                    };
                    vm.forms.Add(formVm);
                }
                projectsVm.Add(vm);
            }


            return(View(projectsVm));
        }