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 <LongWeekendDto[]> LongWeekend([FromRoute] int year, [FromRoute] string countrycode)
        {
            if (!Enum.TryParse(countrycode, true, out CountryCode countryCode))
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }

            var items = DateSystem.GetLongWeekend(year, countryCode);

            return(items.Adapt <LongWeekendDto[]>());
        }
        public ActionResult <LongWeekendDto[]> LongWeekend(
            [FromRoute][Required] int year,
            [FromRoute][Required] string countryCode)
        {
            if (!Enum.TryParse(countryCode, true, out CountryCode parsedCountryCode))
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }

            var items = DateSystem.GetLongWeekend(year, parsedCountryCode);

            return(this.StatusCode(StatusCodes.Status200OK, items.Adapt <LongWeekendDto[]>()));
        }
Example #4
0
        public void LongWeekend()
        {
            var longWeekends = DateSystem.GetLongWeekend(CountryCode.AT, 2017).ToArray();

            Assert.AreEqual(10, longWeekends.Length);
        }
        public void GetLongWeekend_Austria2017_Succcessful()
        {
            var longWeekends = DateSystem.GetLongWeekend(2017, CountryCode.AT).ToArray();

            Assert.AreEqual(10, longWeekends.Length);
        }