예제 #1
0
        public OutboundCallQueueListModel GetOutboundCallQueueList(long callQueueId, long assignedToOrgRoleUserId, int pageNumber, int pageSize, out int totalRecords)
        {
            var callQueueCustomers = _callQueueCustomerRepository.GetCallQueueCustomers(callQueueId, assignedToOrgRoleUserId, pageNumber, pageSize, out totalRecords);

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

            var customerIds = callQueueCustomers.Where(cqc => cqc.CustomerId.HasValue && cqc.CustomerId.Value > 0).Select(cqc => cqc.CustomerId.Value).ToArray();
            IEnumerable <Customer> customers = null;

            if (customerIds.Any())
            {
                customers = _customerRepository.GetCustomers(customerIds);
            }

            var prospectCustomerIds = callQueueCustomers.Where(cqc => cqc.ProspectCustomerId.HasValue && cqc.ProspectCustomerId.Value > 0).Select(cqc => cqc.ProspectCustomerId.Value).ToArray();//&& !cqc.CustomerId.HasValue

            var prospectCustomers = _prospectCustomerRepository.GetProspectCustomers(prospectCustomerIds);


            var prospectCustomerNotes = _customerCallNotesRepository.GetProspectCustomerNotes(prospectCustomers.Select(pc => pc.Id).ToArray());

            var callQueueCriterias = _callQueueCriteriaRepository.GetAllByCallQueueId(callQueueId);
            var criterias          = _criteriaRepository.GetAll();


            var callQueueCustomerCalls                    = _callQueueCustomerCallRepository.GetByCallQueueCustomerIds(callQueueCustomers.Select(cqc => cqc.Id).ToArray());
            IEnumerable <Call>            calls           = null;
            IEnumerable <CallCenterNotes> callCenterNotes = null;

            if (callQueueCustomerCalls != null && callQueueCustomerCalls.Any())
            {
                var callIds = callQueueCustomerCalls.Select(cqcc => cqcc.CallId).ToArray();
                calls           = _callCenterCallRepository.GetByIds(callIds);
                callCenterNotes = _callCenterNotesRepository.GetByCallIds(callIds);
            }
            var idNamePair = GetIdNamePairs(prospectCustomerNotes);

            return(_outboundCallQueueListModelFactory.Create(callQueueCustomers, customers, prospectCustomers, callQueueCriterias, criterias, callQueueCustomerCalls, calls, callCenterNotes, prospectCustomerNotes, idNamePair));
        }