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))); }
//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)); }
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)); }
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); }
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)); }
public bool AddComment(NewComment newComment) { return(m_articleRepository.AddComment(newComment)); }