Ejemplo n.º 1
0
        public ArticleViewModel AddArticle(AddArticleToCategoryInputModel input, string categoryId)
        {
            var article = _mapper.Map <Article>(input);

            _categoryRepository.AddArticle(article, categoryId);
            article.Author = _authorRepository.Find(input.AuthorId);
            return(_mapper.Map <ArticleViewModel>(article));
        }
Ejemplo n.º 2
0
        public IActionResult AddArticleToCategory([FromBody] AddArticleToCategoryInputModel input, string id)
        {
            if (!input.IsValid())
            {
                return(BadRequest(input.ValidationMessage));
            }
            var article = _categoryAppService.AddArticle(input, id);

            return(Created($"/articles/{article.Id}", article));
        }