public async Task <IActionResult> Update([FromForm] ArticleUpdateRequestModel articleUpdateRequestModel)
        {
            var userId             = this.User.GetId();
            var isUpdateSuccessful = await this.articleService.UpdateArticle(articleUpdateRequestModel, userId);

            if (isUpdateSuccessful)
            {
                return(Ok());
            }
            return(BadRequest());
        }
Пример #2
0
        public async Task <bool> UpdateArticle(ArticleUpdateRequestModel articleUpdateRequestModel, string userId)
        {
            var article = await this.GetArticleByIdAndUserId(articleUpdateRequestModel.Id, userId);

            if (article == null)
            {
                return(false);
            }
            article.Title    = articleUpdateRequestModel.Title;
            article.Body     = articleUpdateRequestModel.Body;
            article.TagsJson = articleUpdateRequestModel.TagsJson;

            await this.personalBlogDbContext.SaveChangesAsync();

            return(true);
        }