public OutboundCallQueueListModel GetOutboundCallQueueUpsellAndConfirmation(OutboundCallQueueFilter filter, CallQueue callQueue, int pageSize, long criteriaId, out int totalRecords) { var callQueueCustomers = _callQueueCustomerRepository.GetCallQueueCustomerForUpsellAndConfirmation(filter, filter.PageNumber, pageSize, callQueue, criteriaId, out totalRecords); if (callQueueCustomers.IsNullOrEmpty()) { return(null); } var eventIds = callQueueCustomers.Where(x => x.EventId.HasValue).Select(x => x.EventId.Value).Distinct(); var customerIds = callQueueCustomers.Where(cqc => cqc.CustomerId.HasValue && cqc.CustomerId.Value > 0).Select(cqc => cqc.CustomerId.Value).Distinct().ToArray(); var eventCustomers = _eventCustomerRepository.GetByEventIds(eventIds); eventCustomers = eventCustomers.Where(ec => customerIds.Contains(ec.CustomerId)); var orgRoleUserIds = eventCustomers.Where(ec => ec.DataRecorderMetaData != null && ec.DataRecorderMetaData.DataRecorderCreator != null).Select(ec => ec.DataRecorderMetaData.DataRecorderCreator.Id).ToList(); var registeredbyAgent = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds); var roles = _roleRepository.GetAll(); // var registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray()).ToArray(); var appointment = _appointmentRepository.GetByIds(eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value)); var events = _eventRepository.GetEventswithPodbyIds(eventIds).ToList(); var hosts = _hostRepository.GetEventHosts(eventIds).ToList(); var pods = _podRepository.GetPodsForEvents(eventIds); IEnumerable <Customer> customers = _customerRepository.GetCustomers(customerIds); var callQueueCustomerCalls = _callCenterCallRepository.GetCallForCallQueueCustomerList(customerIds, null); IEnumerable <CallCenterNotes> callCenterNotes = null; if (callQueueCustomerCalls != null && callQueueCustomerCalls.Any()) { callCenterNotes = _callCenterNotesRepository.GetByCallIds(callQueueCustomerCalls.Select(s => s.CallId)); } return(_outboundCallQueueListModelFactory.CallQueueCustomersForUpsellAndConfimration(callQueueCustomers, customers, callQueueCustomerCalls, callCenterNotes, events, hosts, pods, appointment, eventCustomers, registeredbyAgent, roles)); }