コード例 #1
0
        public ActionResult <IEnumerable <RegionStatisticDto> > RegionStatistic()
        {
            var countryCodes = (CountryCode[])Enum.GetValues(typeof(CountryCode));

            var availableCountryCodes = from CountryCode countryCode in countryCodes
                                        where DateSystem.GetPublicHoliday(DateTime.Today.Year, countryCode).Any()
                                        select countryCode;

            var missingCountryCodes = countryCodes.Except(availableCountryCodes);

            var availableCountries = availableCountryCodes.Select(o => this._countryProvider.GetCountry(o.ToString()));
            var missingCountries   = missingCountryCodes.Select(o => this._countryProvider.GetCountry(o.ToString()));

            var regions = (Region[])Enum.GetValues(typeof(Region));

            var regionStatistic = from Region region in regions
                                  where region != Region.None
                                  select new RegionStatisticDto
            {
                RegionName         = region.ToString(),
                AvailableCountries = availableCountries.Where(o => o.Region == region)
                                     .Select(o => CountryHelper.Convert(o))
                                     .OrderBy(o => o.CommonName)
                                     .ToArray(),
                MissingCountries = missingCountries.Where(o => o.Region == region)
                                   .Select(o => CountryHelper.Convert(o))
                                   .OrderBy(o => o.CommonName)
                                   .ToArray(),
            };

            return(View(regionStatistic));
        }
コード例 #2
0
        public ActionResult <CountryInfoDto> CountryInfo(
            [FromRoute][Required] string countryCode = null)
        {
            var country = new Country.CountryProvider().GetCountry(countryCode);

            if (country == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }

            var countryInfo = CountryHelper.Convert(country);

            return(this.StatusCode(StatusCodes.Status200OK, countryInfo));
        }
コード例 #3
0
        public ActionResult <CountryInfoDto> CountryInfo([FromQuery] string countryCode = null)
        {
            if (string.IsNullOrEmpty(countryCode))
            {
                countryCode = this.AutoDetectCountryCode();
            }

            var country = new Country.CountryProvider().GetCountry(countryCode);

            if (country == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }

            var countryInfo = CountryHelper.Convert(country);

            return(StatusCode(StatusCodes.Status200OK, countryInfo));
        }