public FluConsentTemplateListModel GetFluConsentTemplateList(FluConsentTemplateModelFilter filter, int pageNumber, int pageSize, out int totalRecords) { var templates = _fluConsentTemplateRepository.GetTemplates(filter, pageNumber, pageSize, out totalRecords); var healthPlans = _corporateAccountRepository.GetByFluConsentTemplateIds(templates.Select(x => x.Id)); var list = new List <FluConsentTemplateViewModel>(); foreach (var template in templates) { var healthPlanName = "N/A"; var fluConsentHealthPlans = healthPlans.Where(x => x.FluConsentTemplateId == template.Id); if (!fluConsentHealthPlans.IsNullOrEmpty()) { healthPlanName = string.Join(", ", fluConsentHealthPlans.Select(x => x.Name)); } list.Add(new FluConsentTemplateViewModel { Id = template.Id, Name = template.Name, HealthPlan = healthPlanName, IsActive = template.IsActive, IsPublished = template.IsPublished }); } return(new FluConsentTemplateListModel { Collection = list, Filter = filter }); }
public IEnumerable <FluConsentTemplate> GetTemplates(FluConsentTemplateModelFilter filter, int pageNumber, int pageSize, out int totalRecords) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var query = (from fct in linqMetaData.FluConsentTemplate where fct.IsActive select fct); if (!string.IsNullOrWhiteSpace(filter.Name)) { query = (from q in query where q.Name.Contains(filter.Name) select q); } if (filter.HealthPlanId > 0) { var templateIds = (from a in linqMetaData.Account where a.AccountId == filter.HealthPlanId select a.FluConsentTemplateId); query = (from q in query where templateIds.Contains(q.Id) select q); } totalRecords = query.Count(); var entities = query.OrderBy(x => x.Id).TakePage(pageNumber, pageSize).ToArray(); return(Mapper.Map <IEnumerable <FluConsentTemplateEntity>, IEnumerable <FluConsentTemplate> >(entities)); } }
private FluConsentTemplateListModel GetFluConsentTemplateListModel(FluConsentTemplateModelFilter filter, int pageNumber) { int totalRecords; var model = _fluConsentService.GetFluConsentTemplateList(filter, pageNumber, _settings.DefaultPageSizeForReports, out totalRecords); var currentAction = ControllerContext.RouteData.Values["action"].ToString(); Func <int, string> urlFunc = pn => Url.Action(currentAction, new { pageNumber = pn, filter.Name, filter.Active, filter.HealthPlanId }); if (model != null) { model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc); return(model); } return(new FluConsentTemplateListModel { Collection = new List <FluConsentTemplateViewModel>(), Filter = new FluConsentTemplateModelFilter() }); }
public ActionResult Index(FluConsentTemplateModelFilter filter = null, int pageNumber = 1) { return(View(GetFluConsentTemplateListModel(filter, pageNumber))); }