예제 #1
0
        private OrdersConstructorViewModel GetOffalsSource(Order order)
        {
            var offalLabels = new BindingList <OrderConstructorViewModel>();
            var countId     = 0;

            foreach (var x in order.OrderDetail.Where(x => x.Product.IsOffal))
            {
                var label = _labelService.GetLabels(x.Id).LastOrDefault();
                if (label != null)
                {
                    offalLabels.Add(new OrderConstructorViewModel
                    {
                        OrderDetailId = x.Id,
                        ProductId     = x.ProductId,
                        ProductName   = x.Product.EnglishDescription,
                        LocationId    = x.CustomerLocationId,
                        ShipTo        = x.CustomerLocation.Name,
                        Weight        = (decimal)LabelCreateService.GetGrossPoundWeight(label.PoundWeight, _activeLabelType, _orderDetailRepository.Get(x.Id)),
                        Id            = countId++
                    });
                }
            }

            var offals = _productRepository.GetOffalProducts()
                         .Select(x => new OrderConstructorViewModel
            {
                ProductId   = x.Id,
                ProductName = x.Upc
            })
                         .ToList();

            var locations = order.Customer
                            .CustomerLocation
                            .Select(x => new SelectListItemModel
            {
                Id   = x.Id,
                Name = x.Name
            })
                            .ToList();

            var model = new OrdersConstructorViewModel
            {
                ProductNameHeader = "Product Name",
                WeightHeader      = "Box Weight",
                ShipToHeader      = "Ship To",
                QtyHeader         = "Qty",
                Orders            = new BindingList <OrderConstructorViewModel>(offalLabels),
                Constructor       = new BindingList <OrderConstructorViewModel>(offals),
                Locations         = new BindingList <SelectListItemModel>(locations)
            };

            return(model);
        }
예제 #2
0
        private static OrdersConstructorViewModel GetCombosSource(Order order)
        {
            var orders = order.OrderCombos
                         .Select(x => new OrderConstructorViewModel
            {
                Id          = x.Id,
                ProductId   = x.Product.Id,
                ProductName = x.Product.Upc,
                Qty         = x.Quantity,
                LocationId  = x.CustomerLocationId,
                ShipTo      = x.CustomerLocation.Name,
                Weight      = x.Weight
            })
                         .ToList();

            var combos = order.OrderDetail
                         .Where(x => x.Product.Upc.Contains("-Y"))
                         .Select(x => new OrderConstructorViewModel
            {
                ProductId     = x.Product.Id,
                ProductName   = ProductService.GetFormattedProductName(x.Product),
                OrderDetailId = x.Id
            })
                         .ToList();

            var locations = order.Customer
                            .CustomerLocation
                            .Select(x => new SelectListItemModel
            {
                Id   = x.Id,
                Name = x.Name
            })
                            .ToList();

            var model = new OrdersConstructorViewModel
            {
                ProductNameHeader = "Product Name",
                WeightHeader      = "Weight",
                ShipToHeader      = "Ship To",
                QtyHeader         = "Qty",
                Orders            = new BindingList <OrderConstructorViewModel>(orders),
                Constructor       = new BindingList <OrderConstructorViewModel>(combos),
                Locations         = new BindingList <SelectListItemModel>(locations)
            };

            return(model);
        }