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