Beispiel #1
0
        public static JoinPlToVpToProdBindingList GetOrderLines(
            PurOrderId orderId,
            bool shelfOrder,
            List <ProductCategory> categories,
            Dictionary <int, ProductSubCategory> subCategories,
            Dictionary <int, ProductBrand> brands,
            out PurOrder order)
        {
            JoinPlToVpToProdBindingList venprodJoinList = new JoinPlToVpToProdBindingList();

            using (Ambient.DbSession.Activate())
            {
                order = OrderingRepositories.PurOrder.Get(orderId);

                // Create dictionaries of Product and VendorProduct for PurOrder.VendorId and
                // all product categories.
                Dictionary <int, Product>       productDict       = new Dictionary <int, Product>();
                Dictionary <int, VendorProduct> vendorProductDict = new Dictionary <int, VendorProduct>();
                foreach (ProductCategory cat in categories)
                {
                    List <VendorProduct> vendorProducts = OrderingRepositories.VendorProduct.Get(
                        order.VendorId, cat.Id);
                    foreach (VendorProduct vendorProduct in vendorProducts)
                    {
                        vendorProductDict.Add(vendorProduct.Id.Value, vendorProduct);
                    }
                    List <Product> products = OrderingRepositories.Product.Get(order.VendorId, cat.Id);
                    foreach (Product product in products)
                    {
                        productDict.Add(product.Id.Value, product);
                    }
                }

                // Construct a JoinPlToVpToProd for each PurLine in order.
                List <PurLine> purLines;
                if (shelfOrder)
                {
                    purLines = OrderingRepositories.PurLine.GetInShelfOrder(orderId);
                }
                else
                {
                    purLines = OrderingRepositories.PurLine.Get(orderId);
                }
                foreach (PurLine purLine in purLines)
                {
                    VendorProduct    vendorProduct;
                    Product          product;
                    JoinPlToVpToProd join;
                    if (purLine.VendorProductId.IsNull)
                    {
                        // Must have actual objects because some generated
                        // code calls methods of these inner objects.
                        vendorProduct = new VendorProduct();
                        product       = new Product();
                    }
                    else
                    {
                        vendorProduct = vendorProductDict[purLine.VendorProductId.Value];
                        product       = productDict[vendorProduct.ProductId.Value];
                    }
                    join = new JoinPlToVpToProd(purLine, vendorProduct, product);
                    join.SetExternalData(subCategories, brands, order);
                    venprodJoinList.Add(join);
                }
            }
            return(venprodJoinList);
        }
Beispiel #2
0
 public JoinPlToVpToProd()
 {
     mInnerPurLine       = new PurLine();
     mInnerVendorProduct = new VendorProduct();
     mInnerProduct       = new Product();
 }
Beispiel #3
0
 public JoinVpToProd()
 {
     mInnerVendorProduct = new VendorProduct();
     mInnerProduct       = new Product();
 }
Beispiel #4
0
 public JoinPlToVpToProd(PurLine innerPurLine, VendorProduct innerVendorProduct, Product innerProduct)
 {
     mInnerPurLine       = innerPurLine;
     mInnerVendorProduct = innerVendorProduct;
     mInnerProduct       = innerProduct;
 }
Beispiel #5
0
 public JoinVpToProd(VendorProduct innerVendorProduct, Product innerProduct)
 {
     mInnerVendorProduct = innerVendorProduct;
     mInnerProduct       = innerProduct;
 }