private static void UpdateNamesByGemeentenamen(MunicipalityLatestItem syndicationItem, List <GeografischeNaam> gemeentenamen) { if (gemeentenamen == null || !gemeentenamen.Any()) { return; } foreach (var naam in gemeentenamen) { switch (naam.Taal) { default: case Taal.NL: syndicationItem.NameDutch = naam.Spelling; syndicationItem.NameDutchSearch = naam.Spelling.RemoveDiacritics(); break; case Taal.FR: syndicationItem.NameFrench = naam.Spelling; syndicationItem.NameFrenchSearch = naam.Spelling.RemoveDiacritics(); break; case Taal.DE: syndicationItem.NameGerman = naam.Spelling; syndicationItem.NameGermanSearch = naam.Spelling.RemoveDiacritics(); break; case Taal.EN: syndicationItem.NameEnglish = naam.Spelling; syndicationItem.NameEnglishSearch = naam.Spelling.RemoveDiacritics(); break; } } }
private static async Task AddSyndicationItemEntry(AtomEntry <SyndicationContent <Gemeente> > entry, SyndicationContext context, CancellationToken ct) { var municipalityLatestItem = await context .MunicipalityLatestItems .FindAsync(entry.Content.Object.Id); if (municipalityLatestItem == null) { municipalityLatestItem = new MunicipalityLatestItem { MunicipalityId = entry.Content.Object.Id, NisCode = entry.Content.Object.Identificator?.ObjectId, LastUpdatedOn = entry.FeedEntry.LastUpdated, Version = entry.Content.Object.Identificator?.Versie, Position = long.Parse(entry.FeedEntry.Id) }; UpdateNamesByGemeentenamen(municipalityLatestItem, entry.Content.Object.Gemeentenamen); await context .MunicipalityLatestItems .AddAsync(municipalityLatestItem, ct); } else { municipalityLatestItem.NisCode = entry.Content.Object.Identificator?.ObjectId; municipalityLatestItem.LastUpdatedOn = entry.FeedEntry.LastUpdated; municipalityLatestItem.Version = entry.Content.Object.Identificator?.Versie; municipalityLatestItem.Position = long.Parse(entry.FeedEntry.Id); UpdateNamesByGemeentenamen(municipalityLatestItem, entry.Content.Object.Gemeentenamen); } }