예제 #1
0
 public BorgerDkArticle GetArticleFromId(int articleId, BorgerDkMunicipality municipality)
 {
     return(BorgerDkArticle.GetFromArticle(
                this,
                _client.GetArticleByID(articleId, municipality.Code == 0 ? null : (int?)municipality.Code),
                municipality
                ));
 }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
 public static bool TryGetFromCode(string code, out BorgerDkMunicipality municipality)
 {
     municipality = Values.FirstOrDefault(x => x.Code.ToString(CultureInfo.InvariantCulture) == code);
     return(municipality != null);
 }
 public static bool TryGetFromCode(int code, out BorgerDkMunicipality municipality)
 {
     municipality = Values.FirstOrDefault(x => x.Code == code);
     return(municipality != null);
 }