Beispiel #1
0
        public static void QualifyColorGoodnesses(ColorGoodnessRepository colorRepository)
        {
            var colorClassifier = new ColorGoodnessQualifier();

            colorClassifier.Init();

            var colors = colorRepository.GetColorGoodnesses().GetAwaiter().GetResult();

            foreach (var color in colors)
            {
                color.Goodness = (float)colorClassifier.GetColorGoodness((PersonalColorType)color.PersonalColorTypeId, new ServerColor(color.ColorId));
            }

            colorRepository.UpdateColorGoodnesses(colors).GetAwaiter().GetResult();
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            const string path = @"E:\Projects\Zebra\Project\Database\DatabaseData\ParsedData\blouses_shirts.csv";

            var builder = new DbContextOptionsBuilder();

            builder.UseSqlServer(GetConnectionString());
            var context = new ProductContext(builder.Options);

            var productRepo      = new ProductRepository(context);
            var colorRepo        = new ColorGoodnessRepository(context);
            var productColorRepo = new ProductColorGoodnessRepository(context);

            //InitDb(path, CategoryType.BlousesShirts, productRepo, colorRepo, productColorRepo);

            QualifyColorGoodnesses(colorRepo);
            QualifyProductColorGoodnesses(productColorRepo, colorRepo);
        }
Beispiel #3
0
        public static void QualifyProductColorGoodnesses(ProductColorGoodnessRepository productColorRepository, ColorGoodnessRepository colorRepository)
        {
            var productColorGoodness     = productColorRepository.GetProductColorGoodnesses().GetAwaiter().GetResult();
            var productWithColorGoodness = productColorRepository.GetProductWithColorGoodnessAsync().GetAwaiter().GetResult();


            foreach (var colorGoodness in productColorGoodness)
            {
                var product    = productWithColorGoodness.Find(x => x.ProductId == colorGoodness.ProductId);
                var goodnesses = product.ProductColorGoodnesses.Where(x => x.PersonalColorTypeId == colorGoodness.PersonalColorTypeId).Select(x => x.Goodness);
                colorGoodness.Goodness = goodnesses.Max();
            }

            productColorRepository.UpdateColorGoodnesses(productColorGoodness).GetAwaiter().GetResult();
        }
Beispiel #4
0
 public static void InitDb(string fromFilePath, CategoryType categoryType, ProductRepository productRepository, ColorGoodnessRepository colorGoodnessRepo, ProductColorGoodnessRepository productColorRepo)
 {
     FillProduct(fromFilePath, categoryType, productRepository);
     colorGoodnessRepo.FillColorGoodnessesFromProducts().GetAwaiter().GetResult();
     productColorRepo.FillProductColorGoodnessesFromProducts().GetAwaiter().GetResult();
 }