public EventBasicInfoListModel GetEventBasicInfoForCallQueue(FillEventsCallQueueFilter filter, int pageSize, out int totalRecords)
        {
            var criteria = _healthPlanCallQueueCriteriaService.GetSystemGeneratedCallQueueCriteria(filter.CallQueueId, filter.HealthPlanId, filter.AssignedToOrgRoleUserId, 0, filter.CriteriaId);

            if (criteria != null && criteria.IsQueueGenerated == false)
            {
                throw new Exception("Please wait for 10 minutes(max) after you have changed the criteria so that the queue is regenerated.");
            }
            var events = _eventRepository.GetHealthPlanEventsForCallQueue(filter, criteria.Id);

            if (events == null || !events.Any())
            {
                totalRecords = 0;
                return(null);
            }

            var endDate = DateTime.Today.AddDays(criteria.NoOfDays);

            events = events.Where(x => x.EventDate.Date <= endDate.Date);

            var outboundCallQueueFilter = new OutboundCallQueueFilter
            {
                CallQueueId   = criteria.CallQueueId,
                CriteriaId    = criteria.Id,
                HealthPlanId  = criteria.HealthPlanId ?? 0,
                Radius        = 25,
                GmsAccountIds = _settings.GmsAccountIds
            };

            _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(outboundCallQueueFilter);

            var eventIdsWithCustomers = _callQueueCustomerRepository.GetHealthPlanEventsForCriteria(outboundCallQueueFilter);

            events = events.Where(x => (eventIdsWithCustomers.IsNullOrEmpty() || eventIdsWithCustomers.Contains(x.Id)));

            events       = _fillEventsCallQueueHelper.GetAllTheEventFilledUnderPecentage(events, criteria.Percentage);
            totalRecords = events.Count();
            events       = events.OrderBy(ev => ev.EventDate).Skip((filter.PageNumber - 1) * pageSize).Take(pageSize);

            var eventList = _eventCallQueueHelper.EventBasicInfoListForCallQueue(events);

            return(eventList);
        }
Example #2
0
        public ListModelBase <HourlyOutreachCallReportModel, HourlyOutreachCallReportModelFilter> GetOutreachCallReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var calls = _callCenterCallRepository.GetOutreachCallQueueCustomer(filter as OutreachCallReportModelFilter, pageNumber, pageSize, out totalRecords);

            if (calls == null || !calls.Any())
            {
                return(null);
            }

            var customerIds = calls.Select(c => c.CalledCustomerId).ToArray();

            var customerEligibilities = _customerEligibilityRepository.GetCustomerEligibilityByCustomerIdsAndYear(customerIds, DateTime.Today.Year);

            if (customerEligibilities.IsNullOrEmpty())
            {
                customerEligibilities = new List <CustomerEligibility>();
            }

            var callQueueIds = calls.Where(x => x.CallQueueId.HasValue).Select(x => x.CallQueueId.Value).ToArray();

            var callQueues = _callQueueRepository.GetByIds(callQueueIds, false, true);

            var customers = _customerRepository.GetCustomers(customerIds);

            var customerTags = _corporateCustomerCustomTagRepository.GetByCustomerIds(customerIds);

            var eventIds = calls.Where(x => x.EventId > 0).Select(x => x.EventId);

            var events = _eventRepository.GetEventswithPodbyIds(eventIds);

            var organisationRoleIds = calls.Select(c => c.CreatedByOrgRoleUserId).ToArray();

            var callIds = calls.Select(c => c.Id).ToArray();

            EventBasicInfoListModel eventBasicInfoListModel = null;
            List <EventCustomer>    eventCusomters          = null;
            List <Appointment>      appointments            = null;
            IEnumerable <OrderedPair <long, string> > registeredbyAgentNameIdPair = null;

            if (events != null)
            {
                eventBasicInfoListModel = _eventBasicInfoListHelper.EventBasicInfoListForCallQueue(events);
            }

            if (events != null && !customerIds.IsNullOrEmpty())
            {
                eventCusomters = _eventCustomerRepository.GetByCustomerIds(customerIds).Where(s => eventIds.Contains(s.EventId)).ToList();
            }

            if (!eventCusomters.IsNullOrEmpty())
            {
                var appointmentIds = eventCusomters.Where(x => x.AppointmentId.HasValue).Select(x => x.AppointmentId.Value);
                appointments = _appointmentRepository.GetByIds(appointmentIds).ToList();
            }

            if (organisationRoleIds != null && !organisationRoleIds.IsNullOrEmpty())
            {
                registeredbyAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(organisationRoleIds).ToArray();
            }

            var dispositionNotes = _callCenterNotesRepository.GetByCallIds(callIds.ToArray());

            var orderedPairsCustomersShippingDetails = _shippingDetailRepository.GetShippingDetailsIdCustomerId(customerIds);

            var customersShippingDetails   = _shippingDetailRepository.GetShippingDetailsForCustomerIds(customerIds);
            var customerShippingAddressIds = customersShippingDetails.Select(x => x.ShippingAddress.Id).ToList();
            var customerAddress            = _addressRepository.GetAddresses(customerShippingAddressIds);

            return(_outreachCallReportListModelFactory.CreateHourlyModel(customers, customerTags, calls, eventCusomters, eventBasicInfoListModel, appointments, registeredbyAgentNameIdPair, dispositionNotes, orderedPairsCustomersShippingDetails,
                                                                         customersShippingDetails, customerAddress, callQueues, customerEligibilities));
        }