private void ImportProbablyMissingCountries(IEnumerable <CandidateCountry> probablyMissingCountries, IAdditionalRegionsInfoRepository <Data.Entity.Model.Geography.Country> countriesRepository, int typeOfRegionCountryId, IRegionsRepository regionsRepository) { foreach (var probablyMissingCountry in probablyMissingCountries) { if (countriesRepository.Exists(c => c.Code == probablyMissingCountry.Code)) { continue; } var region = new Region { CreatorId = CreatorId }; region.LocalizedRegions.Add(new LocalizedRegion { LanguageId = DefaultLanguageId, Name = probablyMissingCountry.Name, CreatorId = CreatorId }); region.RegionsToTypes.Add(new RegionToType { ToId = typeOfRegionCountryId, CreatorId = CreatorId }); var country = new Data.Entity.Model.Geography.Country { Code = probablyMissingCountry.Code, CreatorId = CreatorId }; region.AdditionalCountryProperties = country; regionsRepository.Add(region); } }
public Data.Entity.Model.Geography.Country[] BuildCountries(Country[] eanCountries, IReadOnlyDictionary <long, int> eanIdsToIds, int creatorId) { var countries = new Queue <Data.Entity.Model.Geography.Country>(); foreach (var eanCountry in eanCountries) { if (!eanIdsToIds.TryGetValue(eanCountry.CountryID, out var id)) { continue; } var country = new Data.Entity.Model.Geography.Country { Id = id, Code = eanCountry.CountryCode, CreatorId = creatorId }; countries.Enqueue(country); } return(countries.ToArray()); }