private static string BuildDescription(PostalInformationSyndicationQueryResult postalInformation, string naamruimte) { if (!postalInformation.ContainsEvent && !postalInformation.ContainsObject) { return("No data embedded"); } var content = new SyndicationContent(); if (postalInformation.ContainsObject) { content.Object = new PostalInfoSyndicationContent( naamruimte, postalInformation.PostalCode, postalInformation.LastChangedOn.ToBelgianDateTimeOffset(), postalInformation.Status, postalInformation.PostalNames, postalInformation.MunicipalityNisCode, postalInformation.Organisation, postalInformation.Reason); } if (postalInformation.ContainsEvent) { var doc = new XmlDocument(); doc.LoadXml(postalInformation.EventDataAsXml); content.Event = doc.DocumentElement; } return(content.ToXml()); }
public static async Task WritePostalInfo( this ISyndicationFeedWriter writer, IOptions <ResponseOptions> responseOptions, AtomFormatter formatter, string category, PostalInformationSyndicationQueryResult postalInformation) { var item = new SyndicationItem { Id = postalInformation.Position.ToString(CultureInfo.InvariantCulture), Title = $"{postalInformation.ChangeType}-{postalInformation.Position}", Published = postalInformation.RecordCreatedAt.ToBelgianDateTimeOffset(), LastUpdated = postalInformation.LastChangedOn.ToBelgianDateTimeOffset(), Description = BuildDescription(postalInformation, responseOptions.Value.Naamruimte) }; if (!string.IsNullOrWhiteSpace(postalInformation.PostalCode)) { item.AddLink( new SyndicationLink( new Uri($"{responseOptions.Value.Naamruimte}/{postalInformation.PostalCode}"), AtomLinkTypes.Related)); item.AddLink( new SyndicationLink( new Uri(string.Format(responseOptions.Value.DetailUrl, postalInformation.PostalCode)), AtomLinkTypes.Self)); item.AddLink( new SyndicationLink( new Uri(string.Format($"{responseOptions.Value.DetailUrl}.xml", postalInformation.PostalCode)), AtomLinkTypes.Alternate) { MediaType = MediaTypeNames.Application.Xml }); item.AddLink( new SyndicationLink( new Uri(string.Format($"{responseOptions.Value.DetailUrl}.json", postalInformation.PostalCode)), AtomLinkTypes.Alternate) { MediaType = MediaTypeNames.Application.Json }); } item.AddCategory( new SyndicationCategory(category)); item.AddContributor( new SyndicationPerson( "agentschap Informatie Vlaanderen", "*****@*****.**", AtomContributorTypes.Author)); await writer.Write(item); }