コード例 #1
0
        public async Task <Entities.Concrete.Article> AddArticle(ArticleAddForDto articleAddForDto)
        {
            var article          = _mapper.Map <Article.Entities.Concrete.Article>(articleAddForDto);
            var articleValidator = new ArticleValidator();
            var resutltValidator = articleValidator.Validate(article);

            if (resutltValidator.Errors.Count > 0)
            {
                throw new ValidationException(resutltValidator.Errors);
            }
            var addedArticle = await _articleDal.AddAsync(article);

            return(addedArticle);
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] ArticleAddForDto articleAddForDto)
        {
            var addedArticle = await _articleService.AddArticle(articleAddForDto);

            return(Ok(addedArticle));
        }