public async Task <ArticleDto> UpdateArticle(int id, CreateUpdateArticleInput input) { if (input.CategoryId <= 0) { throw ExceptionBuilder.Build(HttpStatusCode.BadRequest, new HttpException("category not exist")); } var article = await _articleRepository.FindAsync(id); if (article == null) { throw ExceptionBuilder.Build(HttpStatusCode.NotFound, new HttpException($"Id: {id} not match any article")); } _mapper.Map(input, article); if (input.Title != article.Title) { await _articleManager.SetTitle(article, input.Title); } article.EditTime = DateTime.Now; var updateArticle = await _articleRepository.UpdateAsync(article.Id, article); return(_mapper.Map <Article, ArticleDto>(updateArticle)); }