private void CreateBathAreas(IEnumerable <BathArea> bathAreas) { using (BathContext db = new BathContext()) { db.BathAreas.AddRange(bathAreas); db.SaveChanges(); } }
public void SaveDateToDataBase(string path, IEnumerable <BathArea> bathAreas) { IEnumerable <BathData> datas = _dataReader.ReadAllDataFromDb(); BathData bathData = datas.FirstOrDefault(); if (bathData != null) { return; } string[] fileData = _fileReader.ReadFile(path); datas = _objectCreator.CreateAllBathDataObjects(fileData); CreateBathAreas(bathAreas); using (BathContext db = new BathContext()) { db.BathDatas.AddRange(datas); db.SaveChanges(); } }
public DataReader() { _db = new BathContext(); }