Exemple #1
0
        public LabelGridViewModel GetLabelGridDefinition(int orderId)
        {
            var orderDetails = _orderDetailRepository.GetAllByOrder(orderId).ToArray();
            var locations    = GetCustomerLocations(orderDetails).ToList();

            var result = new LabelGridViewModel
            {
                OrderId   = orderId,
                Locations = locations,
            };

            return(result);
        }
        public IEnumerable <OrderDetailItem> GetItems(int orderId)
        {
            var orderDetails = _orderDetailRepository
                               .GetAllByOrder(orderId)
                               .ToArray();
            List <OrderDetailItem> orderDetailitems = new List <OrderDetailItem>();

            foreach (var orderDetail in orderDetails)
            {
                var orderDetailItem = new OrderDetailItem()
                {
                    Id                 = orderDetail.Id,
                    OrderId            = orderDetail.OrderId,
                    PieceQuantity      = orderDetail.PieceQuantity,
                    ProductId          = orderDetail.ProductId,
                    CustomerLocationId = orderDetail.CustomerLocationId,
                    CustomerLocation   = new OrderDetailCustomerLocationItem
                    {
                        CustomerLocationId   = orderDetail.CustomerLocationId,
                        CustomerLocationName = orderDetail.CustomerLocation.Name
                    },
                    Product = new OrderDetailProductItem
                    {
                        ProductId   = orderDetail.ProductId,
                        ProductName = ProductService.GetFormattedProductName(orderDetail.Product)
                    },
                };
                var product = orderDetail.Product;
                var items   =
                    product.CustomerProductData.Where(x => x.CustomerId == orderDetail.Order.CustomerId);
                var customerProduct = items.FirstOrDefault();
                if (customerProduct != null)
                {
                    orderDetailItem.BagPieceQuantity = customerProduct.PieceQuantity.HasValue
                        ? customerProduct.PieceQuantity.GetValueOrDefault()
                        : 0;
                    orderDetailItem.BoxBagQuantity = customerProduct.BoxQuantity.HasValue
                        ? customerProduct.BoxQuantity.GetValueOrDefault()
                        : 0;
                }
                else
                {
                    orderDetailItem.BagPieceQuantity = orderDetail.Product.BagPieceQuantity;
                    orderDetailItem.BoxBagQuantity   = orderDetail.Product.BoxBagQuantity;
                }
                orderDetailitems.Add(orderDetailItem);
            }

            return(orderDetailitems);
        }