Exemple #1
0
        private static async Task CreateTestInventoryItemsAsync(IConfiguration configuration, IQuiltContextFactory quiltContextFactory, DateTime utcNow)
        {
            var unitOfMeasureCodes = new List <string>
            {
                UnitOfMeasureCodes.FatQuarter,
                UnitOfMeasureCodes.HalfYardage,
                UnitOfMeasureCodes.Yardage,
                UnitOfMeasureCodes.TwoYards,
                UnitOfMeasureCodes.ThreeYards
            };

            var text  = AzureUtility.LoadAzureStringBlob(configuration, "fabrics-default", "index.csv");
            var lines = text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var line in lines)
            {
                var fields = line.Split(new char[] { ',' });

                var sku  = fields[0];
                var name = fields[1];

                //var entry = library.GetEntry(sku);
                //if (entry == null)
                //{
                var image = (Bitmap)AzureUtility.LoadAzureImageBlob(configuration, "fabrics-default", sku + ".jpg");

                var averageColor = GetAverageColor(image);

                _ = await CreateEntryAsync(
                    quiltContextFactory,
                    sku,
                    InventoryItemTypeCodes.Fabric,
                    name,
                    "Kona Cotton Solid", // Collection
                    "Robert Kaufman",    // Manufacturer
                    (int)averageColor.GetHue(),
                    (int)(averageColor.GetSaturation() * 100),
                    (int)(averageColor.GetBrightness() * 100),
                    unitOfMeasureCodes,
                    TestPricingScheduleName,
                    utcNow).ConfigureAwait(false);

                //}
            }
        }