示例#1
0
        public void CsvToDb()
        {
            using StreamReader productsPath = new StreamReader(Settings.Default.ProductsPath),
                  shopsPath = new StreamReader(Settings.Default.ShopsPath);
            var         shops    = CsvParser.ParseShops(shopsPath);
            var         products = CsvParser.ParseProducts(productsPath, shops);
            IDataWorker db       = new DatabaseWorker();

            foreach (var shop in shops)
            {
                db.CreateShop(shop.Key, shop.Value.Name);
            }
            foreach (var product in products)
            {
                db.CreateProduct(product.Name, product.Price, product.Count, product.ShopId);
            }
        }
示例#2
0
 public CsvWorker(StreamReader productFile, StreamReader shopsFile)
 {
     Shops    = CsvParser.ParseShops(shopsFile);
     Products = CsvParser.ParseProducts(productFile, Shops);
 }