Ejemplo n.º 1
0
        public async Task <IActionResult> Put(int id, [FromBody] ArticleUpdateForDto articleUpdateForDto)
        {
            articleUpdateForDto.Id = id;
            var updatedArticle = await _articleService.UpdateArticle(articleUpdateForDto);

            return(Ok(updatedArticle));
        }
Ejemplo n.º 2
0
        public async Task <Entities.Concrete.Article> UpdateArticle(ArticleUpdateForDto articleUpdateForDto)
        {
            var article = await GetArticleById(articleUpdateForDto.Id);

            article.Title       = articleUpdateForDto.Title;
            article.Content     = articleUpdateForDto.Content;
            article.CategoryID  = articleUpdateForDto.CategoryID;
            article.UpdatedDate = articleUpdateForDto.UpdatedDate;


            var articleValidator = new ArticleValidator();
            var resutltValidator = articleValidator.Validate(article);

            if (resutltValidator.Errors.Count > 0)
            {
                throw new ValidationException(resutltValidator.Errors);
            }
            var updatedArticle = _articleDal.Update(article);

            return(updatedArticle);
        }