public ListModelBase <ConfirmationReportViewModel, ConfirmationReportFilter> GetConfirmationReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords) { var confirmationReportFilter = filter as ConfirmationReportFilter ?? new ConfirmationReportFilter(); var confirmationQueueCustomers = _callQueueCustomerRepository.GetForConfirmationReport(confirmationReportFilter, pageNumber, pageSize, out totalRecords); var collection = new List <ConfirmationReportViewModel>(); if (confirmationQueueCustomers.IsNullOrEmpty()) { return(new ConfirmationReportListModel { Collection = new List <ConfirmationReportViewModel>(), Filter = confirmationReportFilter }); } var customerIds = confirmationQueueCustomers.Select(x => x.CustomerId.Value).ToArray(); var customers = _customerRepository.GetCustomers(customerIds); var callQueueCustomerCalls = _callQueueCustomerCallRepository.GetByCallQueueCustomerIds(confirmationQueueCustomers.Select(x => x.Id)); var calls = _callCenterCallRepository.GetCallByCustomerIdAndCallQueue(customerIds, HealthPlanCallQueueCategory.AppointmentConfirmation); var eventIds = confirmationQueueCustomers.Where(x => x.EventId.HasValue && x.EventId.Value > 0).Select(x => x.EventId.Value).ToArray(); var events = _eventService.GetEventBasicInfoEventIds(eventIds); var eventCustomerIds = confirmationQueueCustomers.Where(x => x.EventCustomerId.HasValue).Select(x => x.EventCustomerId.Value).ToArray(); var eventCustomers = _eventCustomerRepository.GetByIds(eventCustomerIds); var eventCustomersByEventIdsAndCustomerIds = _eventCustomerRepository.GetEventCustomersByEventIdsCustomerIds(eventIds, customerIds); if (!eventCustomersByEventIdsAndCustomerIds.IsNullOrEmpty()) { eventCustomersByEventIdsAndCustomerIds = eventCustomersByEventIdsAndCustomerIds.Where(x => !eventCustomerIds.Contains(x.Id)).ToArray(); eventCustomers = eventCustomers.Concat(eventCustomersByEventIdsAndCustomerIds); } var appointments = _appointmentRepository.GetByIds(eventCustomers.Where(ec => ec.AppointmentId.HasValue).Select(ec => ec.AppointmentId.Value).ToList()); var healthPlanIds = confirmationQueueCustomers.Where(x => x.HealthPlanId.HasValue).Select(x => x.HealthPlanId.Value).ToArray(); var healthPlans = _corporateAccountRepository.GetByIds(healthPlanIds); var restrictionIdNamePairs = _corporateAccountRepository.GetRestrictionIdNamePairs(healthPlanIds); var calledByAgentIds = calls.Select(x => x.CreatedByOrgRoleUserId).Distinct().ToArray(); var calledByAgentNameIdPairs = _organizationRoleUserRepository.GetNameIdPairofUsers(calledByAgentIds).ToArray(); var confirmedByAgentIds = eventCustomers.Where(x => x.ConfirmedBy.HasValue).Select(x => x.ConfirmedBy.Value).ToArray(); var confirmedByAgentNameIdPairs = _organizationRoleUserRepository.GetNameIdPairofUsers(confirmedByAgentIds).ToArray(); collection = _confirmationReportingFactory.Create(confirmationQueueCustomers, customers, events, calls, eventCustomers, appointments, healthPlans, restrictionIdNamePairs, confirmedByAgentNameIdPairs, calledByAgentNameIdPairs, callQueueCustomerCalls).ToList(); return(new ConfirmationReportListModel { Collection = collection, Filter = confirmationReportFilter }); }
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)); }