示例#1
0
        private void validate(DataCountry.Root apiCountry)
        {
            var complete = apiCountry != null &&
                           apiCountry.latlng?.Count > 1 &&
                           apiCountry.timezones?.Count > 0 &&
                           apiCountry.languages?.Count > 0 &&
                           apiCountry.currencies?.Count > 0;

            if (!complete)
            {
                throw new Exception("Incomplete base country data");
            }
        }
示例#2
0
        public Country Create(DataCountry.Root apiCountry)
        {
            validate(apiCountry);

            var country = new Country()
            {
                Name       = apiCountry.name,
                Alpha2Code = apiCountry.alpha2Code,
                Coordinate = new Coordinate()
                {
                    Latitude  = apiCountry.latlng[0],
                    Longitude = apiCountry.latlng[1]
                },
                TimeZones  = apiCountry.timezones.Select(t => t),
                Languages  = CreateLanguages(apiCountry.languages),
                Currencies = CreateCurrencies(apiCountry.currencies),
            };

            return(country);
        }