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);
        }
Exemple #2
0
        public ActionResult Index(SurveyTemplateModelFilter filter = null, int pageNumber = 1)
        {
            var totalRecords = 0;
            var list         = _SurveyTemplateService.GetSurveyTemplateList(filter, pageNumber, _pageSize, out totalRecords);

            var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
            Func <int, string> urlFunc = pn => Url.Action(currentAction, new { pageNumber = pn, filter.Name });
            var model = new SurveyTemplateListModel
            {
                Filter      = filter,
                PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc),
                Templates   = list
            };

            return(View(model));
        }
        public IEnumerable <SurveyTemplate> GetTemplatesByFilters(SurveyTemplateModelFilter filter, int pageNumber, int pageSize, out int totalRecords)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var query = linqMetaData.SurveyTemplate.Where(x => x.IsActive);

                if (!string.IsNullOrEmpty(filter.Name))
                {
                    query = query.Where(x => x.Name.Contains(filter.Name));
                }

                totalRecords = query.Count();
                var entities = query.OrderByDescending(p => p.IsActive).OrderBy(p => p.Name).TakePage(pageNumber, pageSize).ToArray();

                return(Mapper.Map <IEnumerable <SurveyTemplateEntity>, IEnumerable <SurveyTemplate> >(entities));
            }
        }