示例#1
0
        public IEnumerable <ShippingViewModel> Get(Guid productId)
        {
            var orderIds = _orderRepository.OrdersForProduct(productId);
            var orders   = orderIds.Select(orderId => _shippingRepository.AssociatedOrder(orderId));


            var shippingData = orderIds.Select(orderId => _shippingRepository.ForOrder(orderId)).ToViewModel();
            var sVM          = new List <ShippingViewModel>();

            foreach (var item in shippingData)
            {
                item.Order    = _orderRepository.Get(item.OrderId).ToViewModel();
                item.Customer = _customerRepository.Get(item.Order.CustomerId).ToViewModel();
                item.Order.ShippingAddress = _shippingRepository.ShippingAddress(item.Order.CustomerId).ToViewModel();
                sVM.Add(item);
            }
            return(sVM);
        }