예제 #1
0
        public ResponseInfoModel EditInfoPause([FromBody] UpdateArticleInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                CheckModelState();

                if (!_articleService.EditInfoPause(input))
                {
                    json.Success = 0;
                    json.Result  = LocalizationConst.UpdateFail;
                }
                else
                {
                    _logService.Insert(new Log()
                    {
                        ActionContent = LocalizationConst.Update,
                        SourceType    = _moduleName,
                        SourceID      = input.ID,
                        LogTime       = DateTime.Now,
                        LogUserID     = input.ModifyUser,
                        LogIPAddress  = IPHelper.GetIPAddress,
                    });
                }
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/article/editInfopause", LocalizationConst.UpdateFail);
            }
            return(json);
        }
예제 #2
0
        public virtual async Task UpdateArticleAsync(UpdateArticleInput input)
        {
            var blog = await _blogManager.Get(input.Id);

            if (blog.CreatorUserId != AbpSession.GetUserId())
            {
                throw new UserFriendlyException("Permission Denied");
            }

            blog.Article.Content = input.Content;
            blog.Article.Title   = input.Title;
        }
예제 #3
0
        public async Task UpdateArticle(string id, UpdateArticleInput input)
        {
            var article = await _articleRepository.GetById(id);

            if (article == null)
            {
                throw new BusinessException("文章不存在!");
            }

            _mapper.Map(input, article);

            await CheckCoverImageExist(input.CoverImage);

            await CheckAttachmentExist(input.AttachmentIds);

            article.Categories = await GetCategorys(input.CategoryIds);

            await _articleRepository.Update(article);
        }
예제 #4
0
        public async Task <UpdateArticlePayload> UpdateArticleAsync(
            UpdateArticleInput input,
            [Service] IDateTimeOffset dateTimeOffset,
            [Service] ITopicEventSender sender,
            [ScopedService] NmediaContext dbContext,
            CancellationToken cancellationToken
            )
        {
            Nmedian?nmedian = null;

            if (input.NmedianId.HasValue)
            {
                nmedian = await dbContext.Nmedians.SingleOrDefaultAsync(
                    x => x.Uuid == input.NmedianId.Value,
                    cancellationToken
                    ) ?? throw new ArgumentException($"The Nmédian (ID={input.NmedianId}) could not be found.", nameof(input));
            }

            Article entity = await dbContext.Articles
                             .SingleOrDefaultAsync(x => x.Uuid == input.Id, cancellationToken)
                             ?? throw new ArgumentException($"The Article (ID={input.Id}) could not be found.", nameof(input));

            entity.Categories = input.Categories;
            entity.Content    = input.Content;
            entity.Nmedian    = nmedian;
            entity.NmedianId  = nmedian?.Id;
            entity.Picture    = input.Picture;
            entity.Published  = input.Published;
            entity.Title      = input.Title;
            entity.Updated    = dateTimeOffset.Now;

            await dbContext.SaveChangesAsync(cancellationToken);

            await sender.SendAsync(nameof(Subscription.OnArticleSaved), entity, cancellationToken);

            return(new UpdateArticlePayload(entity));
        }
예제 #5
0
        public async Task <IActionResult> UpdateArticle(string id, [FromBody] UpdateArticleInput input)
        {
            await _articleService.UpdateArticle(id, input);

            return(NoContent());
        }