public ActionResult Country(string countrycode, int year = 0) { if (year == 0) { year = DateTime.Now.Year; } CountryCode countryCode; if (!Enum.TryParse(countrycode, true, out countryCode)) { return(View("NotFound")); } var isoCountry = Iso3166Countries.GetCountryByAlpha2(countryCode.ToString()); var item = new PublicHolidayInfo(); item.Country = isoCountry.ActiveDirectoryName; item.CountryCode = countrycode; item.Year = year; item.PublicHolidays = DateSystem.GetPublicHoliday(countryCode, year).ToList(); item.LongWeekends = DateSystem.GetLongWeekend(countryCode, year).ToList(); if (item.PublicHolidays.Count > 0) { return(View(item)); } return(View("NotFound")); }
public ActionResult Country(string countrycode, int year = 0) { if (year == 0) { year = DateTime.Now.Year; } CountryCode countryCode; if (!Enum.TryParse(countrycode, true, out countryCode)) { return(View("NotFound")); } var country = Iso3166Countries.GetCountryByAlpha2(countryCode.ToString()); ViewBag.Country = country.ActiveDirectoryName; ViewBag.CountryCode = countrycode; ViewBag.Year = year; ViewBag.NextYear = year + 1; var publicHolidays = DateSystem.GetPublicHoliday(countryCode, year); if (publicHolidays?.Count() > 0) { return(View(publicHolidays)); } return(View("NotFound")); }
private string GetName(CountryCode countryCode) { var country = Iso3166Countries.GetCountryByAlpha2(countryCode.ToString()); return(country.ActiveDirectoryName); }
public CountryIso3166Tests() { countries = new Iso3166Countries(); }
public Iso3166CountriesTests() { countries = new Iso3166Countries(); }
public void GetAlpha2CodeByName_IgnoreCaseTest(string countryName, string result) { var countries = new Iso3166Countries(StringComparer.OrdinalIgnoreCase); Assert.AreEqual(result, countries.GetAlpha2CodeByName(countryName)); }
public void GetAlpha2CodeByName_Test(string countryName, string result) { var countries = new Iso3166Countries(); Assert.AreEqual(result, countries.GetAlpha2CodeByName(countryName)); }