コード例 #1
0
ファイル: DAO.cs プロジェクト: poppasanas/proglabs
        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);
 }