public IEnumerable <ShippingViewModel> Get()
        {
            var shippings = _repository.Get().ToViewModel();

            foreach (var shipping in shippings)
            {
                shipping.Order = _repository.AssociatedOrder(shipping.OrderId).ToViewModel();
                shipping.Order.ShippingAddress = _repository.ShippingAddress(shipping.Order.CustomerId).ToViewModel();
            }
            return(shippings);
        }
Ejemplo n.º 2
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);
        }