コード例 #1
0
        private void createProductBundles(CoolblueContext bundleaddcontext)
        {
            bundleaddcontext.bundles.Add(new ProductBundleItem
            {
                bundleName  = "iphone basic",
                productId   = 1,
                productName = "iphone",
                bundlePrice = 237.50
            });

            bundleaddcontext.bundles.Add(new ProductBundleItem
            {
                bundleName  = "iphone basic",
                productId   = 2,
                productName = "iphone case",
                bundlePrice = 237.50
            });

            bundleaddcontext.bundles.Add(new ProductBundleItem
            {
                bundleName  = "TV bonus",
                productId   = 5,
                productName = "samsung TV",
                bundlePrice = 4845
            });

            bundleaddcontext.bundles.Add(new ProductBundleItem
            {
                bundleName  = "TV bonus",
                productId   = 6,
                productName = "samsung TV HD cable",
                bundlePrice = 4845
            });
            bundleaddcontext.SaveChanges();
        }
コード例 #2
0
        private void createProductBundleAssociation(CoolblueContext prodbundleaddcontext)
        {
            //IPHONE BASIC BUNDLE
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 1,
                productId = 1
            });
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 1,
                productId = 2
            });
            //IPHONE PREMIUM BUNDLE
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 2,
                productId = 1
            });
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 2,
                productId = 2
            });
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 2,
                productId = 3
            });
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 2,
                productId = 4
            });
            //TV PACKAGE BUNDLE
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 3,
                productId = 5
            });
            prodbundleaddcontext.prodbundleassociations.Add(new ProdBundleAssociation
            {
                bundleId  = 3,
                productId = 6
            });

            prodbundleaddcontext.SaveChanges();
        }
コード例 #3
0
        //**************
        //SETUP METHODS (OLD)
        private void createProducts(CoolblueContext productaddcontext)
        {
            productaddcontext.products.Add(new ProductItem
            {
                productName        = "iphone",
                productDescription = "this is an iphone from apple",
                productPrice       = 200
            });

            productaddcontext.products.Add(new ProductItem
            {
                productName        = "iphone screen protector",
                productDescription = "this is an iphone screen protector",
                productPrice       = 20
            });

            productaddcontext.products.Add(new ProductItem
            {
                productName        = "iphone battery",
                productDescription = "this is an iphone battery",
                productPrice       = 120
            });

            productaddcontext.products.Add(new ProductItem
            {
                productName        = "iphone case",
                productDescription = "this is an iphone case",
                productPrice       = 50
            });

            productaddcontext.products.Add(new ProductItem
            {
                productName        = "samsung TV",
                productDescription = "this is a samsung smart tv",
                productPrice       = 5000
            });

            productaddcontext.products.Add(new ProductItem
            {
                productName        = "samsung TV HD cable",
                productDescription = "this is an HDMI cable to be used with samsung smart tv",
                productPrice       = 100
            });
            productaddcontext.SaveChanges();
        }
コード例 #4
0
        private void createBundlesNew(CoolblueContext bundleaddcontext)
        {
            bundleaddcontext.newbundles.Add(new NewBundleItem
            {
                bundleName  = "iphone basic",
                bundlePrice = 237.50
            });

            bundleaddcontext.newbundles.Add(new NewBundleItem
            {
                bundleName  = "iphone premium",
                bundlePrice = 500
            });

            bundleaddcontext.newbundles.Add(new NewBundleItem
            {
                bundleName  = "TV bonus",
                bundlePrice = 4845
            });
            bundleaddcontext.SaveChanges();
        }
コード例 #5
0
        public CoolblueController(CoolblueContext context)
        {
            _context = context;

            //add products
            if (_context.newproducts.Count() == 0)
            {
                createProductsNew(_context);
            }

            //add bundles
            if (_context.newbundles.Count() == 0)
            {
                createBundlesNew(_context);
            }

            //add product bundle associations
            if (_context.prodbundleassociations.Count() == 0)
            {
                createProductBundleAssociation(_context);
            }
        }