private BathData CreateBathDataObject(string[] dataPieces) { int hour = int.Parse(dataPieces[3]); int minute = int.Parse(dataPieces[4]); int second = int.Parse(dataPieces[5]); BathData bathData = new BathData { GuestId = dataPieces[0], BathAreaId = int.Parse(dataPieces[1]) + 1, GuestSate = (GuestSate)int.Parse(dataPieces[2]), CheckingTime = CreateDateTime(hour, minute, second) }; return(bathData); }
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(); } }