예제 #1
0
        public ListModelBase <GiftCertificateReportWellmedViewModel, GiftCertificateReportFilter> GetGiftCertificateWellmedReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var eventCustomers = _eventCustomerRepository.GetForGiftCertificateReport(pageNumber, pageSize, filter as GiftCertificateReportFilter, out totalRecords);

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

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

            var model = _eventReportingService.GetEventVolumeModel(eventCustomers.Select(ec => ec.EventId).ToArray());

            var eventCustomerIds = eventCustomers.Select(ec => ec.Id).ToArray();

            var orders = _orderRepository.GetAllOrdersByEventCustomerIds(eventCustomerIds);

            var orderIds = orders.Select(o => o.Id).ToArray();
            var orderPackageIdNamePair = _eventPackageRepository.GetPackageNamesForOrder(orderIds);
            var orderTestIdNamePair    = _eventTestRepository.GetTestNamesForOrders(orderIds);

            return(_giftCertificateReportWellmedFactory.Create(customers, eventCustomers, model, orders, orderPackageIdNamePair, orderTestIdNamePair));
        }