private ArticleRevisionDto MapArticleToArticleRevisionDto(Article article) { var articleRevisionDto = new ArticleRevisionDto { Id = article.Id, _id = article._id, RevisionId = article.CurrentArticleRevision.Id, Title = article.CurrentArticleRevision.Title, SubTitle = article.CurrentArticleRevision.SubSectionTab.Name, Body = article.CurrentArticleRevision.Body, RevisionDateTime = article.CurrentArticleRevision.RevisionDateTime, SubSectionTabId = article.CurrentArticleRevision.SubSectionTab.Id, Terms = new List <TermDto>(), Files = (article.CurrentArticleRevision.Files != null) ? JsonConvert.DeserializeObject(article.CurrentArticleRevision.Files) : null, Live = article.CurrentArticleRevision.Live, Approval = article.CurrentArticleRevision.Approval, ApprovalComments = article.CurrentArticleRevision.ApprovalComments, Rejected = article.CurrentArticleRevision.Rejected, Departments = new List <DepartmentDto>() }; foreach (var department in article.CurrentArticleRevision.Departments) { articleRevisionDto.Departments.Add(new DepartmentDto() { Id = department.Id, _id = department._id, Name = department.Name, ShortName = department.ShortName }); } if (article.CurrentArticleRevision.Terms == null) { return(articleRevisionDto); } foreach (var term in article.CurrentArticleRevision.Terms) { articleRevisionDto.Terms.Add(new TermDto() { Id = term.Id, Name = term.Name }); } return(articleRevisionDto); }
private List <RelatedArticlesDto> GetRelatedArticlesFromTaxonomyTerms(ArticleRevisionDto articleRevisionDto, IClinicalGuidelinesAppContext db = null) { var relatedArticleDtos = new List <RelatedArticlesDto>(); if (articleRevisionDto.Terms == null) { return(relatedArticleDtos); } foreach (var term in articleRevisionDto.Terms) { relatedArticleDtos.AddRange(GetRelatedArticlesFromTaxonomyTermDto(term, articleRevisionDto.Id, db)); } return(relatedArticleDtos); }
private void CheckArticleRevisionDtoAgainstArticle(ArticleRevisionDto articleRevisionDto) { Assert.AreEqual(_inMemoryArticle.Id, articleRevisionDto.Id); Assert.AreEqual(_inMemoryArticle._id, articleRevisionDto._id); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.Body, articleRevisionDto.Body); Assert.AreEqual(JsonConvert.DeserializeObject(_inMemoryArticle.CurrentArticleRevision.Structure), articleRevisionDto.Structure); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.SubSectionTab.Name, articleRevisionDto.SubTitle); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.Title, articleRevisionDto.Title); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.RevisionDateTime, articleRevisionDto.RevisionDateTime); Assert.AreEqual(_inMemoryArticle.HitCount, articleRevisionDto.Viewed); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.UserId, articleRevisionDto.UserId); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.SubSectionTab.Id, articleRevisionDto.SubSectionTabId); Assert.AreEqual(JsonConvert.DeserializeObject(_inMemoryArticle.CurrentArticleRevision.Files), articleRevisionDto.Files); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.Template, articleRevisionDto.Template); if (articleRevisionDto.Departments != null) { Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.Departments.Count, articleRevisionDto.Departments.Count); for (var i = 0; i < articleRevisionDto.Departments.Count; i++) { Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.Departments[i].Id, articleRevisionDto.Departments[i].Id); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.Departments[i].Name, articleRevisionDto.Departments[i].Name); Assert.AreEqual(_inMemoryArticle.CurrentArticleRevision.Departments[i].ShortName, articleRevisionDto.Departments[i].ShortName); } } if (articleRevisionDto.Terms != null) { foreach (var termDto in articleRevisionDto.Terms) { CheckTermDtoAgainstArticleTerms(termDto, _inMemoryArticle.CurrentArticleRevision.Terms[0]); } } if (articleRevisionDto.RelatedArticleDtos != null) { //Tested separately in the helper class test Assert.AreEqual(0, articleRevisionDto.RelatedArticleDtos.Count); } }
public Log CreateArticleApiControllerLog(LogType notificationType, string method, string requestUri, ArticleRevisionDto article, string samAccountName) { object action; var details = new ArticleDto() { Id = article.Id, _id = article._id, RevisionId = article.RevisionId, Title = article.Title, SubTitle = article.SubTitle }; switch (notificationType) { case LogType.Create: action = new { Action = $"Article created {article.Id}.", Details = details }; break; case LogType.Update: action = new { Action = $"Article updated {article.Id}.", Details = details }; break; default: action = null; break; } return(action != null?CreateLog(samAccountName, method, requestUri, action) : null); }
public ArticleRevisionDto MapRelatedArticleToArticleRevisionDto(ArticleRevisionDto articleRevisionDto, IClinicalGuidelinesAppContext db = null) { return(new ArticleRevisionDto()); }
public ArticleRevisionDto MapRelatedArticleToArticleRevisionDto(ArticleRevisionDto articleRevisionDto, IClinicalGuidelinesAppContext db = null) { articleRevisionDto.RelatedArticleDtos = GetRelatedArticlesFromTaxonomyTerms(articleRevisionDto, db); return(articleRevisionDto); }