public async Task ShouldCreateArticleFromDto() { var articleItem = await TestContentManager.ContentManager.NewAsync("Article"); var articleItemDto = new ArticleItemDto { DisplayText = "Foo", Article = new ArticleDto { Subtitle = new TextFieldDto { Text = "Subtitle" } }, HtmlBodyPart = new HtmlBodyPartDto { Html = "Html" } }; articleItem.FromDto(articleItemDto); var subtitle = articleItem.Content.Article.Subtitle.Text.ToString(); var html = articleItem.Content.HtmlBodyPart.Html.ToString(); Assert.Equal("Foo", articleItem.DisplayText); Assert.Equal("Subtitle", subtitle); Assert.Equal("Html", html); }
public async Task <ActionResult <ArticleItem> > GetArticleById([FromRoute] int articleId) { ArticleItemDto articleItemDto = await _articleRepository.GetArticleById(articleId); ArticleItem articleItem = _mapper.Map <ArticleItem>(articleItemDto); return(Ok(articleItem)); }
public async Task <ArticleItemDto> GetArticle(string url, CancellationToken cancellationToken) { ArticleItemDto dto = new ArticleItemDto(); HtmlDocument doc = await HtmlAgilityHelper.GetHtmlDocument(url, cancellationToken); var raw = doc.ToString(); //TODO : return(dto); }
private List <ArticleItemDto> ProcessCatchUpElements(string pageTitleInfo, string dateInfo, HtmlNode[] dtelem_list, HtmlNode[] ddelem_list, bool includeAbstract) { List <ArticleItemDto> result = new List <ArticleItemDto>(); if (dtelem_list == null || dtelem_list.Length < 1 || ddelem_list == null || ddelem_list.Length < 1) { return(result); } int loopCount = Math.Min(dtelem_list.Count(), ddelem_list.Count()); for (int i = 0; i < loopCount; i++) { var item = new { arxivIdInnerText = dtelem_list[i]?.InnerText, dtdesc = dtelem_list[i].Descendants("a"), dddesc = ddelem_list[i].Descendants() }; ArticleItemDto dto = new ArticleItemDto(); dto.PageHeaderInfo = pageTitleInfo; dto.DateContextInfo = dateInfo; dto.ArxivIdLabel = GetDtArxivIdLabel(item.arxivIdInnerText); dto.ArxivId = GetDtElementInnerText(item.dtdesc, "Abstract"); dto.AbstractUrl = GetDtElementAttributeValue(item.dtdesc, "Abstract"); dto.PdfUrl = GetDtElementAttributeValue(item.dtdesc, "Download PDF"); dto.OtherFormatUrl = GetDtElementAttributeValue(item.dtdesc, "Other formats"); dto.Title = GetDDElementTitle(item.dddesc, "div", "class", "list-title mathjax", "Title:"); dto.Comments = GetDDElementComment(item.dddesc, "list-comments mathjax"); dto.AbstractText = includeAbstract ? GetDDElementAbstract(item.dddesc, "mathjax") : string.Empty; dto.PrimarySubject = GetDDElementPrimarySubject(item.dddesc, "div", "class", "list-subjects", ")"); dto.SubjectItems = GetDDElementSubjects(item.dddesc, "div", "class", "list-subjects"); dto.Authors = GetDDElementAuthors(item.dddesc, "div", "class", "list-authors"); result.Add(dto); } return(result); }
public JsonResult Update(ArticleItemDto dto) { var result = _articleItemContract.Update(dto); return(Json(result)); }
public ActionResult Create(ArticleItemDto dto) { var result = _articleItemContract.Insert(dto); return(Json(result)); }