public ListModelBase <ResponseVendorReportViewModel, ResponseVendorReportFilter> GetResponseVendorReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords) { filter = filter ?? new ResponseVendorReportFilter(); var responseVendorReportFilter = filter as ResponseVendorReportFilter ?? new ResponseVendorReportFilter(); var customerIds = _customerRepository.GetCustomersByCustomTag(filter as ResponseVendorReportFilter, pageNumber, pageSize, out totalRecords); //var customerIds = _callRepository.GetForResponseVendorReport(filter as ResponseVendorReportFilter, pageNumber, pageSize, out totalRecords); if (customerIds.IsNullOrEmpty()) { return(null); } var customerEligibilities = _customerEligibilityRepository.GetCustomerEligibilityByCustomerIdsAndYear(customerIds, DateTime.Today.Year); if (customerEligibilities.IsNullOrEmpty()) { customerEligibilities = new List <CustomerEligibility>(); } var corporateAccount = _corporateAccountRepository.GetById(((ResponseVendorReportFilter)filter).AccountId); var calls = _callRepository.GetCallsForResponseVendorReport(filter as ResponseVendorReportFilter, customerIds); var customers = customerIds.Any() ? _customerRepository.GetCustomers(customerIds.ToArray()) : new List <Customer>(); var eventCustomers = _eventCustomerRepository.GetByEventIdsOrCustomerIds(responseVendorReportFilter.StartDate, customerIds) ?? new List <EventCustomer>(); var eventIds = eventCustomers.Select(x => x.EventId).ToArray(); var events = _eventRepository.GetByIds(eventIds); var languages = _languageRepository.GetAll(); var appointmentIds = eventCustomers.Where(x => x.AppointmentId.HasValue).Select(x => x.AppointmentId.Value); var appointments = _appointmentRepository.GetByIds(appointmentIds); var eventCustomerIds = eventCustomers.Select(x => x.Id); var pcpAppointments = _pcpAppointmentRepository.GetByEventCustomerIds(eventCustomerIds); var pcpDispositions = _pcpDispositionRepository.GetByEventCustomerIds(eventCustomerIds); var eventCustomerBarriers = _barrierRepository.GetCustomerBarrierByEventCustomerIds(eventCustomerIds); var barrierIds = eventCustomerBarriers.Select(x => x.BarrierId).ToArray(); var barriers = _barrierRepository.GetByIds(barrierIds); var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds); var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds.ToArray()); var chaseCampaignIds = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct(); var chaseCampaigns = _chaseCampaignRepository.GetByIds(chaseCampaignIds); var campaignTypeIds = chaseCampaigns.Select(x => x.ChaseCampaignTypeId).ToArray(); var campaignTypes = _chaseCampaignTypeRepository.GetByIds(campaignTypeIds); var eventAppointmentCancellatonLogs = _eventAppointmentCancellationLogRepository.GetByEventCustomerIds(eventCustomerIds); var resultPostedToPlanFileName = Path.Combine(_settings.ResultPostedToPlanPath, string.Format("resultPostedto_{0}.xml", corporateAccount.Tag)); var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); var resultPostedCustomers = resultPosted != null ? resultPosted.Customer : new List <CustomerInfo>(); return(_responseVendorReportFactory.Create(customers, languages, eventCustomers, appointments, events, calls, pcpAppointments, pcpDispositions, eventCustomerBarriers, barriers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns, campaignTypes, eventAppointmentCancellatonLogs, resultPostedCustomers, customerEligibilities)); }