public ListModelBase <ActualCustomerShowedViewModel, PayPeriodBookedCustomerFilter> GetActualCustomerShowed(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var payPeriodBookedCustomerFilter = filter != null ? filter as PayPeriodBookedCustomerFilter : new PayPeriodBookedCustomerFilter();
            var eventcustomers = _eventCustomerRepository.GetActualCustomerShowed(pageNumber, pageSize, payPeriodBookedCustomerFilter, out totalRecords);

            if (eventcustomers.IsNullOrEmpty())
            {
                return(null);
            }

            var appointments = _appointmentRepository.GetByIds(eventcustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList());

            var eventIds  = eventcustomers.Select(ec => ec.EventId).Distinct().ToArray();
            var model     = _eventReportingService.GetEventVolumeModel(eventcustomers.Select(ec => ec.EventId).Distinct().ToArray());
            var customers = _customerRepository.GetCustomers(eventcustomers.Select(ec => ec.CustomerId).Distinct().ToArray());
            var orders    = _orderRepository.GetAllOrdersByEventCustomerIds(eventcustomers.Select(ec => ec.Id).ToArray(), true);

            var eventPackages = _eventPackageRepository.GetbyEventIds(eventIds);
            var eventTests    = _eventTestRepository.GetByEventIds(eventIds);

            var orgRoleUserIds = eventcustomers.Where(ec => ec.DataRecorderMetaData != null && ec.DataRecorderMetaData.DataRecorderCreator != null).Select(ec => ec.DataRecorderMetaData.DataRecorderCreator.Id).ToList();
            var registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()).ToArray();

            var payPeriodStartDate = (DateTime?)eventcustomers.OrderBy(x => x.DataRecorderMetaData.DateCreated).Select(x => x.DataRecorderMetaData.DateCreated).FirstOrDefault();
            var payPeriodEndDate   = eventcustomers.IsNullOrEmpty() ? null : (DateTime?)eventcustomers.OrderByDescending(x => x.DataRecorderMetaData.DateCreated).Select(x => x.DataRecorderMetaData.DateCreated).FirstOrDefault();

            var payPeriods = payPeriodStartDate.HasValue && payPeriodEndDate.HasValue ? _payPeriodRepository.GetPayPeriods(payPeriodStartDate.Value, payPeriodEndDate.Value) : null;

            var payRangesCustomerBooked = new List <PayRangeCustomerBookedViewModel>();

            if (payPeriods != null)
            {
                SetEndDateforPayPeriod(payPeriods);

                payPeriods = payPeriods.OrderBy(s => s.StartDate);

                foreach (var payPeriod in payPeriods)
                {
                    payRangesCustomerBooked.AddRange(GetPayRange(payPeriod, eventcustomers));
                }

                foreach (var payRange in payRangesCustomerBooked)
                {
                    var customerbookedbyAgents = _payPeriodRepository.GetPayPeriodBookingCountForAgent(payRange.StartDate, payRange.EndDate, payPeriodBookedCustomerFilter.AgentId);
                    payRange.TotalCustomerBookedByAgent = customerbookedbyAgents;
                }
            }

            var criterias = payPeriods.IsNullOrEmpty() ? null : _payPeriodCriteriaRepository.GetByPayPeriodId(payPeriods.Select(x => x.Id).ToArray());

            var listModel = _payPeriodBookedCustomerFactory.CreateActualCustomerShowed(eventcustomers, appointments, orders, model, customers, eventPackages, eventTests, payPeriods, criterias, payRangesCustomerBooked);

            listModel.RegisteredBy = registeredbyAgentNameIdPair.Any() ? registeredbyAgentNameIdPair.First().SecondValue : "";
            listModel.Filter       = payPeriodBookedCustomerFilter;

            return(listModel);
        }