public ActionResult Index(HealthPlanRevenueListModelFilter filter = null, int pageNumber = 1) { int totalRecords; var model = _healthPlanRevenueService.GetHealthPlanRevenues(filter, pageNumber, _pageSize, out totalRecords) ?? new HealthPlanRevenueListModel(); filter = filter ?? new HealthPlanRevenueListModelFilter(); model.Filter = filter; var currentAction = ControllerContext.RouteData.Values["action"].ToString(); Func <int, string> urlFunc = pn => Url.Action(currentAction, new { pageNumber = pn, filter.HealthPlanId }); model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc); return(View(model)); }
public HealthPlanRevenueListModel GetHealthPlanRevenues(HealthPlanRevenueListModelFilter filter, int pageNumber, int pageSize, out int totalRecords) { var healthPlans = _corporateAccountRepository.GetHealthPlanbyFilter(pageNumber, pageSize, filter, out totalRecords); if (healthPlans.IsNullOrEmpty()) { return(null); } var healthPlanRevenues = _healthPlanRevenueRepository.GetByHealthPlanIds(healthPlans.Select(x => x.Id)); var healthPlanRevenueViewModelList = new List <HealthPlanRevenueViewModel>(); var listModel = new HealthPlanRevenueListModel(); foreach (var corporateAccount in healthPlans) { var revenueCustomerPair = _healthPlanRevenueHelper.GetHealthplanRevenue(healthPlanRevenues.Where(x => x.AccountId == corporateAccount.Id)); var model = new HealthPlanRevenueViewModel { HealthPlanName = corporateAccount.Name, HealthPlanId = corporateAccount.Id, }; if (revenueCustomerPair != null && revenueCustomerPair.Any()) { model.ShowDetails = true; model.TotalCustomer = revenueCustomerPair.Sum(x => x.FirstValue); model.Revenue = revenueCustomerPair.Sum(x => x.SecondValue); } healthPlanRevenueViewModelList.Add(model); } listModel.Collection = healthPlanRevenueViewModelList; return(listModel); }
public IEnumerable <CorporateAccount> GetHealthPlanbyFilter(int pageNumber, int pageSize, HealthPlanRevenueListModelFilter filter, out int totalRecords) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var entities = linqMetaData.Account.Where(a => a.IsHealthPlan); if (filter.HealthPlanId > 0) { entities = linqMetaData.Account.Where(a => a.IsHealthPlan && a.AccountId == filter.HealthPlanId); } totalRecords = entities.Count(); var finalEntities = entities.TakePage(pageNumber, pageSize).WithPath(path => path.Prefetch(a => a.Organization)).OrderBy(a => a.Organization.Name).ToArray(); return(Mapper.MapMultiple(finalEntities)); } }