Exemple #1
0
        public List <SurveyTemplateViewModel> GetSurveyTemplateList(SurveyTemplateModelFilter filter, int pageNumber, int pageSize, out int totalRecords)
        {
            var list      = new List <SurveyTemplateViewModel>();
            var templates = _SurveyTemplateRepository.GetTemplatesByFilters(filter, pageNumber, pageSize, out totalRecords);

            if (templates.IsNullOrEmpty())
            {
                return(list);
            }

            var healthPlans = _corporateAccountRepository.GetBySurveyTemplateIds(templates.Select(x => x.Id));

            foreach (var SurveyTemplate in templates)
            {
                var healthPlanName    = "N/A";
                var SurveyhealthPlans = healthPlans.Where(x => x.SurveyTemplateId == SurveyTemplate.Id);
                if (!SurveyhealthPlans.IsNullOrEmpty())
                {
                    healthPlanName = string.Join(", ", SurveyhealthPlans.Select(x => x.Name));
                }

                list.Add(new SurveyTemplateViewModel
                {
                    Name        = SurveyTemplate.Name,
                    HealthPlan  = healthPlanName,
                    Id          = SurveyTemplate.Id,
                    IsActive    = SurveyTemplate.IsActive,
                    IsPublished = SurveyTemplate.IsPublished,
                });
            }
            return(list);
        }