コード例 #1
0
        public ListModelBase <PcpTrackingReportViewModel, PcpTrackingReportFilter> GetPcpTrackingReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var pcpTrackingFilter = filter as PcpTrackingReportFilter ?? new PcpTrackingReportFilter();

            var collection = new List <PcpTrackingReportViewModel>();

            var customers = _customerRepository.GetForPcpTrackingReport(pageNumber, pageSize, pcpTrackingFilter, out totalRecords);

            if (customers.IsNullOrEmpty())
            {
                return(new PcpTrackingReportListModel
                {
                    Collection = collection,
                    Filter = pcpTrackingFilter
                });
            }

            var customerIds           = customers.Select(x => x.CustomerId).ToArray();
            var primaryCarePhysicians = _primaryCarePhysicianRepository.GetAllByCustomerIds(customerIds);

            var tags          = customers.Select(x => x.Tag).ToArray();
            var healthPlans   = _corporateAccountRepository.GetByTags(tags);
            var organizations = _organizationRepository.GetOrganizations(healthPlans.Select(hp => hp.Id).ToArray());

            collection = _pcpTrackingReportFactory.Create(customers, primaryCarePhysicians, healthPlans, organizations).ToList();

            return(new PcpTrackingReportListModel
            {
                Collection = collection,
                Filter = pcpTrackingFilter
            });
        }