private static void UpdateNames(StreetNameBosaItem syndicationItem, IReadOnlyCollection <GeografischeNaam> streetNames) { if (streetNames == null || !streetNames.Any()) { return; } foreach (var naam in streetNames) { switch (naam.Taal) { default: case Taal.NL: syndicationItem.NameDutch = naam.Spelling; syndicationItem.NameDutchSearch = naam.Spelling.SanitizeForBosaSearch(); break; case Taal.FR: syndicationItem.NameFrench = naam.Spelling; syndicationItem.NameFrenchSearch = naam.Spelling.SanitizeForBosaSearch(); break; case Taal.DE: syndicationItem.NameGerman = naam.Spelling; syndicationItem.NameGermanSearch = naam.Spelling.SanitizeForBosaSearch(); break; case Taal.EN: syndicationItem.NameEnglish = naam.Spelling; syndicationItem.NameEnglishSearch = naam.Spelling.SanitizeForBosaSearch(); break; } } }
private static void UpdateHomonymAdditions(StreetNameBosaItem syndicationItem, IReadOnlyCollection <GeografischeNaam> homonymAdditions) { if (homonymAdditions == null || !homonymAdditions.Any()) { return; } foreach (var naam in homonymAdditions) { switch (naam.Taal) { default: case Taal.NL: syndicationItem.HomonymAdditionDutch = naam.Spelling; break; case Taal.FR: syndicationItem.HomonymAdditionFrench = naam.Spelling; break; case Taal.DE: syndicationItem.HomonymAdditionGerman = naam.Spelling; break; case Taal.EN: syndicationItem.HomonymAdditionEnglish = naam.Spelling; break; } } }
private static async Task AddSyndicationItemEntry(AtomEntry <SyndicationItem <StreetName> > entry, SyndicationContext context, CancellationToken ct) { var latestItem = await context .StreetNameBosaItems .FindAsync(entry.Content.Object.StreetNameId); if (latestItem == null) { latestItem = new StreetNameBosaItem { StreetNameId = entry.Content.Object.StreetNameId, NisCode = entry.Content.Object.NisCode, Version = entry.Content.Object.Identificator?.Versie, Position = long.Parse(entry.FeedEntry.Id), PersistentLocalId = entry.Content.Object.Identificator?.ObjectId, IsComplete = entry.Content.Object.IsComplete, }; UpdateNames(latestItem, entry.Content.Object.StreetNames); UpdateHomonymAdditions(latestItem, entry.Content.Object.HomonymAdditions); await context .StreetNameBosaItems .AddAsync(latestItem, ct); } else { latestItem.NisCode = entry.Content.Object.NisCode; latestItem.Version = entry.Content.Object.Identificator?.Versie; latestItem.Position = long.Parse(entry.FeedEntry.Id); latestItem.PersistentLocalId = entry.Content.Object.Identificator?.ObjectId; latestItem.IsComplete = entry.Content.Object.IsComplete; UpdateNames(latestItem, entry.Content.Object.StreetNames); UpdateHomonymAdditions(latestItem, entry.Content.Object.HomonymAdditions); } }