public static void Initialize(SentryDbContext c) { c.Database.EnsureCreated(); if (c.Currencies.Any()) { return; } var list = new List <string>(); var regions = SystemRegionInfo.GetRegionsList(); foreach (var r in regions) { if (!SystemRegionInfo.IsCountry(r)) { continue; } if (list.Contains(r.ISOCurrencySymbol)) { continue; } var e = CurrencyObjectFactory.Create(r); c.Currencies.Add(e.DbRecord); list.Add(r.ISOCurrencySymbol); } c.SaveChanges(); }
public static void Initialize(SentryDbContext c) { c.Database.EnsureCreated(); if (c.CountryCurrencies.Any()) { return; } var regions = SystemRegionInfo.GetRegionsList(); foreach (var r in regions) { if (!SystemRegionInfo.IsCountry(r)) { continue; } var x = new CountryCurrencyDbRecord(); x.CountryID = r.ThreeLetterISORegionName; x.CurrencyID = r.ISOCurrencySymbol; c.CountryCurrencies.Add(x); } c.SaveChanges(); }
private static void testWorld() { var r = new RegionInfo("001"); Assert.IsNotNull(r); Assert.IsFalse(SystemRegionInfo.IsCountry(r)); Assert.AreEqual("World", r.EnglishName); }
private void testEstonia() { var r = new RegionInfo("et-EE"); Assert.IsNotNull(r); Assert.IsTrue(SystemRegionInfo.IsCountry(r)); Assert.AreEqual("Estonia", r.EnglishName); }
public void GetRegionsListTest() { var l = SystemRegionInfo.GetRegionsList(); Assert.IsInstanceOfType(l, typeof(List <RegionInfo>)); Assert.IsTrue(l.Count > 100); Assert.IsTrue(l[0].EnglishName.StartsWith("A")); }
private static void testEstoniaCurrency() { var r = new RegionInfo("et-EE"); Assert.IsNotNull(r); Assert.IsTrue(SystemRegionInfo.IsCurrency(r)); Assert.AreEqual("Euro", r.CurrencyEnglishName); }
private Dictionary <string, string> getCountryCodesDictionary() { var countryCodesMapping = new Dictionary <string, string>(); foreach (RegionInfo region in SystemRegionInfo.GetRegionsList()) { countryCodesMapping.Add(region.DisplayName, region.ThreeLetterISORegionName); } return(countryCodesMapping); }
[TestMethod] public void InitializeTest() { TestCleanup(); CountriesDbTableInitializer.Initialize(db); var l = SystemRegionInfo.GetRegionsList(); for (var i = l.Count; i > 0; i--) { var c = l[i - 1]; if (SystemRegionInfo.IsCountry(c)) { continue; } l.Remove(c); } Assert.AreEqual(l.Count, db.Countries.Count()); }
public static void Initialize(ICurrencyObjectsRepository c) { if (c.IsInitialized()) { return; } var regions = SystemRegionInfo.GetRegionsList(); foreach (var r in regions) { if (!SystemRegionInfo.IsCountry(r)) { continue; } var e = CurrencyObjectFactory.Create(r); c.AddObject(e); } }
public static void Initialize(ApplicationDbContext c) { c.Database.EnsureCreated(); if (c.Countries.Any()) { return; } var regions = SystemRegionInfo.GetRegionsList(); foreach (var r in regions) { if (!SystemRegionInfo.IsCountry(r)) { continue; } var e = CountryFactory.Create(r); c.Countries.Add(e.Data); } c.SaveChanges(); }
public static IHtmlContent EditingControlsForCountry <TModel, TResult>( this IHtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TResult> > expression) { var countryList = new List <string>(); foreach (RegionInfo region in SystemRegionInfo.GetRegionsList()) { countryList.Add(region.DisplayName); } var selectList = new SelectList(countryList); var htmlStrings = new List <object> { new HtmlString("<div class=\"form-group\">"), htmlHelper.LabelFor(expression, new { @class = "control-label" }), htmlHelper.DropDownListFor(expression, selectList, new { @class = "form-control" }), htmlHelper.ValidationMessageFor(expression, "", new { @class = "text-danger" }), new HtmlString("</div>"), }; return(new HtmlContentBuilder(htmlStrings)); }
public void InitializeTest() { TestCleanup(); CurrenciesDbTableInitializer.Initialize(db); var l = SystemRegionInfo.GetRegionsList(); var a = new List <string>(); for (var i = l.Count; i > 0; i--) { var c = l[i - 1]; if (!SystemRegionInfo.IsCountry(c)) { continue; } if (a.Contains(c.ISOCurrencySymbol)) { continue; } a.Add(c.ISOCurrencySymbol); } Assert.AreEqual(a.Count, db.Currencies.Count()); }
public void IsCountryTest() { Assert.IsFalse(SystemRegionInfo.IsCountry(null)); testEstonia(); testWorld(); }
public void IsCurrencyTest() { Assert.IsFalse(SystemRegionInfo.IsCurrency(null)); testEstoniaCurrency(); }