public ListModelBase <AppointmentsShowedViewModel, CallCenterBonusFilter> GetAppointmentsShowed(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var callCenterbounsFilter = filter as CallCenterBonusFilter;

            if (callCenterbounsFilter == null || callCenterbounsFilter.StartDate == null || callCenterbounsFilter.EndDate == null || callCenterbounsFilter.StartDate.Value > callCenterbounsFilter.EndDate.Value)
            {
                totalRecords = 0;
                return(null);
            }
            var callCenterAgents = _payPeriodRepository.GetIdNamePairofUsersByRoleOrParentRole(callCenterbounsFilter, pageNumber, pageSize, out totalRecords);

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

            var agentIds = callCenterAgents.Select(s => s.FirstValue);

            var eventcustomers = _eventCustomerRepository.GetEventCustomerForBonusCalculation(callCenterbounsFilter.StartDate.Value, callCenterbounsFilter.EndDate.Value, agentIds);

            var payPeriodStartDate = eventcustomers.IsNullOrEmpty() ? null : (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);

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

                foreach (var payRange in payRangesCustomerBooked)
                {
                    var customerbookedbyAgents = _payPeriodRepository.GetTotalBookedCustomerCount(payRange.StartDate, payRange.EndDate, agentIds);
                    payRange.CustomerBookedByAgents = customerbookedbyAgents;
                }
            }

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

            var collection = _callCenterBonusReportingFactory.Create(callCenterAgents, eventcustomers, payPeriods, criterias, payRangesCustomerBooked);

            return(new AppointmentsShowedListModel {
                Collection = collection
            });
        }