private void InsertDefaultValues() { CountryInfo country = new CountryInfo(); country.Name = "International"; country.Code = "None"; CCountryGateway countryGateway = new CCountryGateway(); countryGateway.Create(country); Upgrade(); }
internal override void GetVersion() { /*this version is for putting default values in db (the names of all existing countries)*/ /*-- get countries from text file --*/ if (File.Exists(_fileWithCountries)) { List <CountryInfo> countries = new List <CountryInfo>(); using (StreamReader sr = new StreamReader(_fileWithCountries)) { String ln; while ((ln = sr.ReadLine()) != null) { String[] arr = ln.Split(' '); List <String> arr2 = new List <string>(); foreach (var s in arr) { if (s != "") { arr2.Add(s); } } StringBuilder str = new StringBuilder(); for (var i = 0; i < arr2.Count - 3; i++) { str.AppendFormat(arr2[i]); str.AppendFormat(" "); } countries.Add(new CountryInfo { Code = arr2[arr2.Count - 2], Name = str.ToString() }); } } CCountryGateway countryGateway = new CCountryGateway(); foreach (var country in countries) { countryGateway.Create(country); } Upgrade(); } else { SLogger.Log.Error($"Can't find file {_fileWithCountries}"); } }