Esempio n. 1
0
        public IActionResult CreateArticle(Guid authorId, [FromBody] ArticleCreateDTO articleCreateModel)
        {
            if (articleCreateModel == null)
            {
                return(BadRequest());
            }

            var articleEntity = _mapper.Map <Article>(articleCreateModel);

            _articleRepository.AddArticleForAuthor(authorId, articleEntity);
            if (!_articleRepository.Save())
            {
                throw new Exception("Kayit sirasinda hata olustu");
            }

            return(CreatedAtRoute("GetArticlesForAuthor",
                                  new { authorId = articleEntity.AuthorId },
                                  articleEntity));
        }