public async Task <bool> EditArticle(EditArticleDto article, string userId) { var oldArticle = await this.dbContext.Articles.FindAsync(article.Id); if (oldArticle != null && oldArticle.UserId == userId) { oldArticle.Title = article.Title; oldArticle.Content = article.Content; } return(await this.dbContext.SaveChangesAsync() > 0); }
public async Task <IActionResult> Edit(EditArticleDto article) { var userId = this.usersManager.GetUserId(this.User); var success = await this.articlesService.EditArticle(article, userId); if (success) { return(Ok()); } return(StatusCode(StatusCodes.Status500InternalServerError)); }