Exemple #1
0
        private static void CreateStandardStates(IConfiguration configuration, IQuiltContextFactory quiltContextFactory)
        {
            var text  = AzureUtility.LoadAzureStringBlob(configuration, "database-load", "states.csv");
            var lines = text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            using var ctx = quiltContextFactory.Create();

            var dbCountry = ctx.Countries.Where(r => r.CountryCode == "US").SingleOrDefault();

            if (dbCountry == null)
            {
                dbCountry = new Country()
                {
                    CountryCode = "US",
                    Name        = "United States"
                };
                _ = ctx.Countries.Add(dbCountry);
            }

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

                var stateCode   = fields[0];
                var name        = fields[1];
                var countryCode = fields[2];

                CreateState(ctx, stateCode, name, countryCode);
            }

            _ = ctx.SaveChanges();
        }
Exemple #2
0
        public static JToken AzureLoad(IConfiguration configuration, string name)
        {
            var text = AzureUtility.LoadAzureStringBlob(configuration, "libraries", string.Format("{0}.json", name));

            var json = JToken.Parse(text);

            return(json);
        }
Exemple #3
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);

                //}
            }
        }