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 ListModelBase <RefundRequestBasicInfoModel, RefundRequestListModelFilter> GetPendingRequests(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords) { var refundRequestFilter = filter as RefundRequestListModelFilter; var requests = _refundRequestRepository.Get(pageNumber, pageSize, refundRequestFilter, out totalRecords); if (requests == null || requests.Count() < 1) { return(null); } var customerIds = requests.Select(r => r.CustomerId).ToArray(); var customers = _customerRepository.GetCustomers(customerIds); var eventIds = requests.Select(r => r.EventId).Distinct().ToArray(); var eventCustomers = _eventCustomerRepository.GetEventCustomersByEventIdsCustomerIds(eventIds, customerIds); var appointmentCancellationLog = new List <EventAppointmentCancellationLog>(); if (!eventCustomers.IsNullOrEmpty()) { var cancellationLog = _eventAppointmentCancellationLogRepository.GetByEventCustomerIds(eventCustomers.Select(x => x.Id)); if (!cancellationLog.IsNullOrEmpty()) { appointmentCancellationLog.AddRange(cancellationLog); } } var events = _eventRepository.GetEventswithPodbyIds(eventIds); var hosts = _hostRepository.GetEventHosts(eventIds); var orders = _orderRepository.GetOrderByOrderIds(requests.Select(r => r.OrderId)); var orgRoleUserIds = requests.Select(r => r.RequestedByOrgRoleUserId).Distinct().ToArray(); if (refundRequestFilter.RefundRequestStatus < 0 || refundRequestFilter.RefundRequestStatus == (int)RequestStatus.Resolved || refundRequestFilter.RefundRequestStatus == (int)RequestStatus.Reverted) { var processedbyOrgRoleUserIds = requests.Where(r => r.RefundRequestResult != null).Select(r => r.RefundRequestResult.ProcessedByOrgRoleUserId).Distinct().ToArray(); if (processedbyOrgRoleUserIds.Count() > 0) { orgRoleUserIds = orgRoleUserIds.Concat(processedbyOrgRoleUserIds).ToArray(); } } var bookedByOrgRoleUserIds = orders.Select(o => o.DataRecorderMetaData.DataRecorderCreator.Id).ToArray(); orgRoleUserIds = orgRoleUserIds.Concat(bookedByOrgRoleUserIds).ToArray(); var idNamePairs = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds); var organizationRoleUsers = _organizationRoleUserRepository.GetOrganizationRoleUsers(orgRoleUserIds); var roles = _roleRepository.GetAll(); return(_refundRequestListFactory.Create(requests, customers, events, hosts, idNamePairs, organizationRoleUsers, roles, orders, eventCustomers, appointmentCancellationLog)); }