Beispiel #1
0
        private ArticleDto InsertArticle(ArticleDto dto)
        {
            Share.Models.Article.Entities.Article article = _mapper.Map <Share.Models.Article.Entities.Article>(dto);
            RepositoryResult result = _articleRepository.Create(article);

            if (!result.Succeeded)
            {
                throw new Exception(string.Join(",", result.Errors));
            }
            return(dto);
        }
Beispiel #2
0
        public ArticleDto UpdateArticleWithCommitHistory(ArticleDto articleDto)
        {
            Share.Models.Article.Entities.Article articleExisting = _articleRepository.Entities.Include(a => a.ArticleLicense).Single(a => a.ArticleId == articleDto.ArticleId);
            if (!string.Equals(articleExisting?.ArticleLicense?.License, articleDto?.ArticleLicenseDto?.License))
            {
                articleDto.ArticleLicenseDto.LicensedDate = DateTime.UtcNow;
            }
            articleExisting = _mapper.Map <ArticleDto, Share.Models.Article.Entities.Article>(articleDto, articleExisting);
            int        i             = _articleRepository.SaveChanges();
            ArticleDto articleDtoNew = _mapper.Map <ArticleDto>(articleExisting);

            return(articleDtoNew);
        }