public void LoadData_should_read_excel_data() { var spreadsheet = new LocalitiesSpreadsheet(); var results = spreadsheet.LoadData(); var collection = results as Locality[] ?? results.ToArray(); Assert.NotEmpty(collection); var data = collection.Single(x => x.Postcode == "6023"); data.Suburb.Should().Be("DUNCRAIG"); }
private void ImportLocalities() { var ss = new LocalitiesSpreadsheet(); foreach (var item in ss.LoadData().Where(x => !string.IsNullOrEmpty(x.Suburb))) { var found = _localitiesRepository.Find(x => !string.IsNullOrWhiteSpace(x.Suburb) && x.Suburb.Trim() == item.Suburb.Trim()); var xxx = found.ToList(); if (xxx.Any()) { Log.Debug("Locality skipped {desc}", item.Suburb); continue; } item.Id = Guid.NewGuid(); Log.Information(item.ToString()); _busControl.Publish(new LocalityRequest { Locality = item.TrimAllStrings() }); _localitiesRepository.Save(item); } }