Example #1
0
        public IActionResult Post([FromBody] JObject value)
        {
            if (value == null)
            {
                return(BadRequest());
            }

            try
            {
                var articleVm = value.ToObject <ArticleViewModel>();
                var article   = _mapper.Map <ArticleEntity>(articleVm);

                var id = _articleBll.AddArticle(article);

                if (id == -1)
                {
                    return(BadRequest());
                }

                return(Created("", new { id }));
            }
            catch
            {
                return(BadRequest());
            }
        }
Example #2
0
 public IHttpActionResult AddArticle([FromBody] AddArticleModel articleModel)
 {
     if (string.IsNullOrEmpty(articleModel.Article.Topic) || string.IsNullOrEmpty(articleModel.Article.Status))
     {
         return(BadRequest());
     }
     if (_bll.AddArticle(articleModel))
     {
         return(Ok());
     }
     return(InternalServerError());
 }