Ejemplo n.º 1
0
        public ListModelBase <LabsInboundViewModel, LabsInboundFilter> GetLabsInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new LabsInboundFilter();

            var customerEventTestStates = _customerEventTestStateRepository.GetForLabInboundReport(filter as LabsInboundFilter, pageNumber, pageSize, out totalRecords);

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

            var customerEventScreeningTestIds = customerEventTestStates.Select(x => x.CustomerEventScreeningTestId).Distinct();
            var customerEventScreeningTests   = _eventCustomerResultRepository.GetCustomerEventScreeningTestsByIds(customerEventScreeningTestIds);

            var testIds = customerEventScreeningTests.Select(x => x.TestId).Distinct();
            var tests   = _testRepository.GetTestByIds(testIds);

            var eventCustomerResultIds = customerEventScreeningTests.Select(x => x.EventCustomerResultId).Distinct();
            var eventCustomerResults   = _eventCustomerResultRepository.GetByIds(eventCustomerResultIds);
            var eventCustomers         = _eventCustomerRepository.GetByIds(eventCustomerResultIds);

            var eventIds    = eventCustomers.Select(x => x.EventId).Distinct();
            var events      = _eventRepository.GetByIds(eventIds);
            var customerIds = eventCustomers.Select(x => x.CustomerId).Distinct().ToArray();
            var customers   = _customerRepository.GetCustomers(customerIds);

            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds);
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            return(_labsInboundReportFactory.Create(customerEventTestStates, customerEventScreeningTests, eventCustomers, customers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns, tests, events, eventCustomerResults));
        }
        public ListModelBase <InterviewInboundViewModel, InterviewInboundFilter> GetInterviewInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new InterviewInboundFilter();
            var interviewInboundFilter = filter as InterviewInboundFilter ?? new InterviewInboundFilter();

            var responseVendorReportFilter = new ResponseVendorReportFilter
            {
                StartDate  = interviewInboundFilter.StartDate,
                EndDate    = interviewInboundFilter.EndDate,
                AccountId  = interviewInboundFilter.AccountId,
                CustomTags = interviewInboundFilter.CustomTags
            };

            var customerIds = _customerRepository.GetCustomersByCustomTag(responseVendorReportFilter, pageNumber, pageSize, out totalRecords);

            //var customerIds = _callRepository.GetForInterviewReport(filter as InterviewInboundFilter, pageNumber, pageSize, out totalRecords);
            if (customerIds.IsNullOrEmpty())
            {
                return(null);
            }

            var calls = _callRepository.GetCallsForInterviewReport(filter as InterviewInboundFilter, customerIds);

            var customers = customerIds.Any() ? _customerRepository.GetCustomers(customerIds.ToArray()) : new List <Customer>();

            //var eventCustomers = _eventCustomerRepository.GetEventCustomersByEventIdsCustomerIds(eventIds, customerIds) ?? new List<EventCustomer>();
            var eventCustomers   = _eventCustomerRepository.GetByEventIdsOrCustomerIds(interviewInboundFilter.StartDate, customerIds) ?? new List <EventCustomer>();
            var eventCustomerIds = eventCustomers.Select(x => x.Id);

            var eventIds = eventCustomers.Select(x => x.EventId).ToArray();
            var events   = _eventRepository.GetEvents(eventIds);

            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds.ToArray());
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            var appointmentIds = eventCustomers.Where(x => x.AppointmentId.HasValue).Select(x => x.AppointmentId.Value);
            var appointments   = _appointmentRepository.GetByIds(appointmentIds);

            var eventAppointmentCancellatonLogs = _eventAppointmentCancellationLogRepository.GetByEventCustomerIds(eventCustomerIds);

            var noteIds           = eventAppointmentCancellatonLogs.Where(x => x.NoteId.HasValue).Select(x => x.NoteId.Value);
            var customerCallNotes = _customerCallNotesRepository.GetByIds(noteIds);

            var eventIdStaffIdPairs = _eventRepository.GetEventStaffPairs(eventIds);

            var orgRoleUserIds        = eventIdStaffIdPairs.Select(x => x.SecondValue).Distinct().ToArray();
            var organizationRoleUsers = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds);

            var userIds = organizationRoleUsers.Select(x => x.UserId).Distinct().ToList();
            var users   = _userRepository.GetUsers(userIds);

            return(_interviewInboundReportFactory.Create(eventCustomers, customers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns, calls, appointments, events, eventAppointmentCancellatonLogs, customerCallNotes, eventIdStaffIdPairs,
                                                         organizationRoleUsers, users));
        }
        public ListModelBase <ConditionInboundViewModel, ConditionInboundFilter> GetConditionInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new ConditionInboundFilter();

            var diagnosisRecords = _eventCustomerDiagnosisRepository.GetForConditionInboundReport(filter as ConditionInboundFilter, pageNumber, pageSize, out totalRecords);

            if (!diagnosisRecords.Any())
            {
                return(null);
            }

            var eventCustomerIds = diagnosisRecords.Select(x => x.EventCustomerId).Distinct().ToArray();
            var eventCustomers   = _eventCustomerRepository.GetByIds(eventCustomerIds);

            var customerIds    = eventCustomers.Select(x => x.CustomerId).Distinct().ToArray();
            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds);
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            return(_conditionInboundReportFactory.Create(diagnosisRecords, eventCustomers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns));
        }
        public ListModelBase <BarrierInboundViewModel, BarrierInboundFilter> GetBarrierInboundReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new BarrierInboundFilter();

            var eventCustomerBarriers = _barrierRepository.GetForBarrierInboundReport(filter as BarrierInboundFilter, pageNumber, pageSize, out totalRecords);

            var barrierIds = eventCustomerBarriers.Select(x => x.BarrierId).ToArray();
            var barriers   = _barrierRepository.GetByIds(barrierIds);

            var eventCustomerIds = eventCustomerBarriers.Select(x => x.EventCustomerId);
            var eventCustomers   = _eventCustomerRepository.GetByIds(eventCustomerIds);

            var customerIds = eventCustomers.Select(x => x.CustomerId).ToArray();
            var customers   = customerIds.Any() ? _customerRepository.GetCustomers(customerIds) : null;

            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds);
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            return(_barrierInboundReportFactory.Create(eventCustomerBarriers, barriers, eventCustomers, customers, chaseOutbounds, customerChaseCampaigns, chaseCampaigns));
        }
        public ListModelBase <ResponseVendorReportViewModel, ResponseVendorReportFilter> GetResponseVendorReportList(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            filter = filter ?? new ResponseVendorReportFilter();
            var responseVendorReportFilter = filter as ResponseVendorReportFilter ?? new ResponseVendorReportFilter();

            var customerIds = _customerRepository.GetCustomersByCustomTag(filter as ResponseVendorReportFilter, pageNumber, pageSize, out totalRecords);

            //var customerIds = _callRepository.GetForResponseVendorReport(filter as ResponseVendorReportFilter, pageNumber, pageSize, out totalRecords);
            if (customerIds.IsNullOrEmpty())
            {
                return(null);
            }

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

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

            var corporateAccount = _corporateAccountRepository.GetById(((ResponseVendorReportFilter)filter).AccountId);

            var calls = _callRepository.GetCallsForResponseVendorReport(filter as ResponseVendorReportFilter, customerIds);

            var customers = customerIds.Any() ? _customerRepository.GetCustomers(customerIds.ToArray()) : new List <Customer>();

            var eventCustomers = _eventCustomerRepository.GetByEventIdsOrCustomerIds(responseVendorReportFilter.StartDate, customerIds) ?? new List <EventCustomer>();

            var eventIds = eventCustomers.Select(x => x.EventId).ToArray();
            var events   = _eventRepository.GetByIds(eventIds);

            var languages = _languageRepository.GetAll();

            var appointmentIds = eventCustomers.Where(x => x.AppointmentId.HasValue).Select(x => x.AppointmentId.Value);
            var appointments   = _appointmentRepository.GetByIds(appointmentIds);

            var eventCustomerIds = eventCustomers.Select(x => x.Id);
            var pcpAppointments  = _pcpAppointmentRepository.GetByEventCustomerIds(eventCustomerIds);
            var pcpDispositions  = _pcpDispositionRepository.GetByEventCustomerIds(eventCustomerIds);

            var eventCustomerBarriers = _barrierRepository.GetCustomerBarrierByEventCustomerIds(eventCustomerIds);

            var barrierIds = eventCustomerBarriers.Select(x => x.BarrierId).ToArray();
            var barriers   = _barrierRepository.GetByIds(barrierIds);

            var chaseOutbounds = _chaseOutboundRepository.GetByCustomerIds(customerIds);

            var customerChaseCampaigns = _chaseCampaignRepository.GetCustomerChaseCampaignsByCustomerIds(customerIds.ToArray());
            var chaseCampaignIds       = customerChaseCampaigns.Select(x => x.ChaseCampaignId).Distinct();
            var chaseCampaigns         = _chaseCampaignRepository.GetByIds(chaseCampaignIds);

            var campaignTypeIds = chaseCampaigns.Select(x => x.ChaseCampaignTypeId).ToArray();
            var campaignTypes   = _chaseCampaignTypeRepository.GetByIds(campaignTypeIds);

            var eventAppointmentCancellatonLogs = _eventAppointmentCancellationLogRepository.GetByEventCustomerIds(eventCustomerIds);

            var resultPostedToPlanFileName = Path.Combine(_settings.ResultPostedToPlanPath, string.Format("resultPostedto_{0}.xml", corporateAccount.Tag));
            var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName);

            var resultPostedCustomers = resultPosted != null ? resultPosted.Customer : new List <CustomerInfo>();

            return(_responseVendorReportFactory.Create(customers, languages, eventCustomers, appointments, events, calls, pcpAppointments, pcpDispositions, eventCustomerBarriers, barriers, chaseOutbounds, customerChaseCampaigns,
                                                       chaseCampaigns, campaignTypes, eventAppointmentCancellatonLogs, resultPostedCustomers, customerEligibilities));
        }