Exemple #1
0
        protected virtual async Task CreateArticleInfoAsync(CreateOrUpdateArticleInfoDto input)
        {
            if (_articleInfoRepository.GetAll().Any(p => p.Title == input.ArticleInfo.Title))
            {
                throw new UserFriendlyException(L("TitleExist"));
            }

            var articleInfo = new ArticleInfo()
            {
                Code                  = GetCode(),
                Title                 = input.ArticleInfo.Title,
                Publisher             = input.ArticleInfo.Publisher,
                ColumnInfoId          = input.ArticleInfo.ColumnInfoId,
                ArticleSourceInfoId   = input.ArticleInfo.ArticleSourceInfoId,
                ReleaseTime           = input.ArticleInfo.ReleaseTime?.ToLocalTime(),
                Content               = input.ArticleInfo.Content,
                IsActive              = input.ArticleInfo.IsActive,
                IsNeedAuthorizeAccess = input.ArticleInfo.IsNeedAuthorizeAccess,
                SeoTitle              = input.ArticleInfo.SeoTitle,
                KeyWords              = input.ArticleInfo.KeyWords,
                Introduction          = input.ArticleInfo.Introduction,
                StaticPageUrl         = input.ArticleInfo.StaticPageUrl,
                Url             = input.ArticleInfo.Url,
                IsStatic        = input.ArticleInfo.IsStatic,
                RecommendedType = input.ArticleInfo.RecommendedType,
                CreatorUserId   = AbpSession.UserId,
                CreationTime    = Clock.Now,
                TenantId        = AbpSession.TenantId
            };
            await _articleInfoRepository.InsertAsync(articleInfo);
        }
Exemple #2
0
        protected virtual async Task UpdateArticleInfoAsync(CreateOrUpdateArticleInfoDto input)
        {
            Debug.Assert(input.ArticleInfo.Id != null, "必须设置input.ArticleInfo.Id的值");

            var articleInfo = await _articleInfoRepository.GetAsync(input.ArticleInfo.Id.Value);

            if (input.ArticleInfo.Title != articleInfo.Title)
            {
                if (_articleInfoRepository.GetAll().Any(p => p.Title == input.ArticleInfo.Title))
                {
                    throw new UserFriendlyException(L("TitleExist"));
                }
            }
            articleInfo.Title                 = input.ArticleInfo.Title;
            articleInfo.Publisher             = input.ArticleInfo.Publisher;
            articleInfo.ColumnInfoId          = input.ArticleInfo.ColumnInfoId;
            articleInfo.ArticleSourceInfoId   = input.ArticleInfo.ArticleSourceInfoId;
            articleInfo.ReleaseTime           = input.ArticleInfo.ReleaseTime?.ToLocalTime();
            articleInfo.Content               = input.ArticleInfo.Content;
            articleInfo.IsActive              = input.ArticleInfo.IsActive;
            articleInfo.IsNeedAuthorizeAccess = input.ArticleInfo.IsNeedAuthorizeAccess;
            articleInfo.SeoTitle              = input.ArticleInfo.SeoTitle;
            articleInfo.KeyWords              = input.ArticleInfo.KeyWords;
            articleInfo.Introduction          = input.ArticleInfo.Introduction;
            articleInfo.StaticPageUrl         = input.ArticleInfo.StaticPageUrl;
            articleInfo.Url             = input.ArticleInfo.Url;
            articleInfo.RecommendedType = input.ArticleInfo.RecommendedType;
            articleInfo.IsStatic        = input.ArticleInfo.IsStatic;
        }
Exemple #3
0
        private bool CheckMaxItemCount(CreateOrUpdateArticleInfoDto input)
        {
            var columnInfoMaxItemCount = _columnInfoRepository.Get(input.ArticleInfo.ColumnInfoId).MaxItemCount;

            if (!columnInfoMaxItemCount.HasValue)
            {
                return(true);
            }
            var columnInfoCurrentCount = _articleInfoRepository.GetAll().Count(a => a.ColumnInfoId == input.ArticleInfo.ColumnInfoId);

            return(columnInfoMaxItemCount > columnInfoCurrentCount);
        }
Exemple #4
0
        public async Task CreateOrUpdateArticleInfo(CreateOrUpdateArticleInfoDto input)
        {
            //处理Html图片
            if (!string.IsNullOrWhiteSpace(input.ArticleInfo.Content))
            {
                input.ArticleInfo.Content = await _editorHelper.ConvertBase64ImagesForContent(input.ArticleInfo.Content);
            }

            if (!CheckMaxItemCount(input))
            {
                throw new UserFriendlyException(L("ExceedTheMaxCount"));
            }
            if (!input.ArticleInfo.Id.HasValue)
            {
                await CreateArticleInfoAsync(input);
            }
            else
            {
                await UpdateArticleInfoAsync(input);
            }
        }