예제 #1
0
        internal static void ImportCategoriesProducts()
        {
            int[] products   = jsonService.GetProductsIds();
            int[] categories = jsonService.GetCategoriesIds();
            List <CategoryProduct> categoriesProducts = new List <CategoryProduct>();

            for (int index = 0; index < products.Length; index++)
            {
                HashSet <int> categoryIndexes = new HashSet <int>();
                for (int count = 0; count < 3; count++)
                {
                    categoryIndexes.Add(random.Next(0, categories.Length));
                }

                foreach (var integer in categoryIndexes)
                {
                    int productID  = products[index];
                    int categoryID = categories[integer];
                    categoriesProducts.Add(new CategoryProduct(categoryID, productID));
                }
            }
            jsonService.AddCategoriesProductsRange(categoriesProducts);
        }