Ejemplo n.º 1
0
        public async Task <IActionResult> CreateCommentAsync([FromBody] CommentDto commentDto)
        {
            var comment = _mapper.Map <Comment>(commentDto);

            comment.Author = _mapper.Map <Author>(User);

            return(Ok(await _repository.AddComment(comment)));
        }
Ejemplo n.º 2
0
        //http://localhost:50357/api/article/addcomment
        public async Task <IActionResult> AddComment(Comment comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            articleRepository.AddComment(comment);
            await unitOfWork.Complete();

            return(Ok(comment));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <ArticleCommentDto> > AddComment(int id, ArticleCommentRequest model)
        {
            var article = await _repository.GetById(id);

            if (article == null)
            {
                return(NotFound(ArticleNotFound));
            }

            var result = await _repository.AddComment(id, model);

            return(result != null
                ? Created(nameof(AddComment), result)
                : StatusCode(StatusCodes.Status500InternalServerError, null));
        }
Ejemplo n.º 4
0
        public MethodResult CreateComment(int articleID, int entityID, string content)
        {
            ArticleComment comment = new ArticleComment()
            {
                ArticleID    = articleID,
                AuthorID     = entityID,
                Content      = content,
                CreationDate = DateTime.Now,
                CreationDay  = GameHelper.CurrentDay
            };

            articleRepository.AddComment(comment);
            articleRepository.SaveChanges();
            return(MethodResult.Success);
        }
Ejemplo n.º 5
0
        public HttpResponseMessage Add(CommentRequest commentRequest)
        {
            //check of article exists
            var article = _articleRepository.GetArticleById(commentRequest.ArticleId);

            var comment = new Comment
            {
                Id        = commentId++,
                Text      = commentRequest.Message,
                ArticleId = article.Id
            };

            _articleRepository.AddComment(comment);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Ejemplo n.º 6
0
 public bool AddComment(NewComment newComment)
 {
     return(m_articleRepository.AddComment(newComment));
 }