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); } }
public CsvWorker(StreamReader productFile, StreamReader shopsFile) { Shops = CsvParser.ParseShops(shopsFile); Products = CsvParser.ParseProducts(productFile, Shops); }