public static BorgerDkArticle GetFromArticle(BorgerDkHttpService service, Article article, BorgerDkMunicipality municipality) { // Check if "service" or "article" is null if (service == null) { throw new ArgumentNullException(nameof(service)); } if (article == null) { throw new ArgumentNullException(nameof(article)); } return(new BorgerDkArticle(service, article, municipality ?? BorgerDkMunicipality.NoMunicipality)); }
private BorgerDkArticle(BorgerDkHttpService service, Article article, BorgerDkMunicipality municipality) { // Check if "service" or "article" is null if (service == null) { throw new ArgumentNullException(nameof(service)); } if (article == null) { throw new ArgumentNullException(nameof(article)); } municipality = municipality ?? BorgerDkMunicipality.NoMunicipality; // Get the Danish time zone TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time"); // Assume the timstamp are specified according to the Danish time zone DateTimeOffset published = new DateTimeOffset(article.PublishingDate, tz.GetUtcOffset(article.PublishingDate)); DateTimeOffset updated = new DateTimeOffset(article.LastUpdated, tz.GetUtcOffset(article.LastUpdated)); // Populate basic properties Id = article.ArticleID; Domain = service.Endpoint.Domain; Url = article.ArticleUrl.Split('?')[0]; Municipality = municipality; Title = HttpUtility.HtmlDecode(article.ArticleTitle); Header = HttpUtility.HtmlDecode(article.ArticleHeader); PublishDate = new EssentialsTime(published, tz); UpdateDate = new EssentialsTime(updated, tz); Content = article.Content; Elements = ParseElements(Content); ByLine = StringUtils.StripHtml(Elements.OfType <BorgerDkTextElement>().FirstOrDefault(x => x.Id == "byline")?.Content); }
public static BorgerDkArticle GetFromArticle(BorgerDkHttpService service, Article article) { return(GetFromArticle(service, article, null)); }