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

            try
            {
                var commentVm = value.ToObject <CommentViewModel>();
                var comment   = _mapper.Map <CommentEntity>(commentVm);

                var id = _commentBll.AddComment(comment);

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

                return(Created("", new { id }));
            }
            catch
            {
                return(BadRequest());
            }
        }