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"));
        }
Example #2
0
        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"));
        }
Example #3
0
        private string GetName(CountryCode countryCode)
        {
            var country = Iso3166Countries.GetCountryByAlpha2(countryCode.ToString());

            return(country.ActiveDirectoryName);
        }
 public CountryIso3166Tests()
 {
     countries = new Iso3166Countries();
 }
 public Iso3166CountriesTests()
 {
     countries = new Iso3166Countries();
 }
Example #6
0
        public void GetAlpha2CodeByName_IgnoreCaseTest(string countryName, string result)
        {
            var countries = new Iso3166Countries(StringComparer.OrdinalIgnoreCase);

            Assert.AreEqual(result, countries.GetAlpha2CodeByName(countryName));
        }
Example #7
0
        public void GetAlpha2CodeByName_Test(string countryName, string result)
        {
            var countries = new Iso3166Countries();

            Assert.AreEqual(result, countries.GetAlpha2CodeByName(countryName));
        }
Example #8
0
 public void GetAlpha2CodeByName_IgnoreCaseTest(string countryName, string result)
 {
     var countries = new Iso3166Countries(StringComparer.OrdinalIgnoreCase);
     Assert.AreEqual(result, countries.GetAlpha2CodeByName(countryName));
 }
Example #9
0
 public void GetAlpha2CodeByName_Test(string countryName, string result)
 {
     var countries = new Iso3166Countries();
     Assert.AreEqual(result, countries.GetAlpha2CodeByName(countryName));
 }