Exemplo n.º 1
0
        public async Task <IActionResult> AddArticleToStore(ArticleRequestDto article)
        {
            var articleDB = _mapper.Map <Article>(article);
            var store     = _databaseProvider.GetStore(article.StoreId);

            if (store == null)
            {
                return(NotFound(new ErrorResponse()
                {
                    ErrorCode = 404, ErrorMessage = MessageConstants.StoreNotFoundMessage
                }));
            }
            _databaseProvider.AddArticleToStore(articleDB);
            await _databaseProvider.Save();


            return(CreatedAtAction("GetArticles", _mapper.Map <ArticleDto>(articleDB)));
        }