Пример #1
0
        public Location Generate(Country country)
        {
            List <WorldCityRecord> cities = _worldCitiesLoader.GetRecords().Value;

            WorldCityRecord city = _listRandomiser.GetRandomisedItem(cities, record => record.CountryCodeIso2 == country.RegionInfo.TwoLetterISORegionName);

            return(new Location(new City(city.City), country));
        }
Пример #2
0
        public Lastname Generate(Gender gender, Country country)
        {
            List <LastnameRecord> lastnameRecords = _lastnameRecordsLoader.GetRecords(country);

            if (lastnameRecords == null)
            {
                throw new ApplicationException("Cannot find any lastname record.");
            }

            var lastname = _listRandomiser.GetRandomisedItem(lastnameRecords)
                           .Lastname;

            return(new Lastname(lastname));
        }
Пример #3
0
        public Firstname Generate(Gender gender, Country country)
        {
            List <string> languages = country.Languages
                                      .Select(l => l.Value.ToLower())
                                      .ToList();

            List <FirstnameRecord> firstnamesRecords = _firstnameRecordsLoader.GetRecords().Value
                                                       .Where(r => r.Genders.Contains(gender) &&
                                                              r.Frequency > 0d &&
                                                              languages.Any(l => r.Languages.Contains(l)))
                                                       .ToList();

            if (firstnamesRecords == null)
            {
                throw new ApplicationException("Cannot find any firstname record.");
            }

            FirstnameRecord record = _listRandomiser.GetRandomisedItem(firstnamesRecords);

            return(new Firstname(record.Firstname));
        }
Пример #4
0
        public PercentileGrowth GeneratePercentileGrowth(Gender gender)
        {
            AbstractPercentileGrowthSet growthSet = _percentileGrowthSetRepository.GetPercentileGrowthSet(gender);

            if (growthSet == null)
            {
                return(null);
            }

            List <PercentileGrowth> items = growthSet.Growths.ToList();

            return(_listRandomiser.GetRandomisedItem(items));
        }