public async Task <IActionResult> UpdateCommentAsync([FromRoute] int postId, [FromRoute] int commentId, [FromBody] CommentUpdateModel model) { var comment = await _postRepository.GetCommentByIdAsync(commentId); if (!await _postRepository.AnyByIdAsync(postId)) { throw new NotFound404Exception("post"); } if (comment == null) { throw new NotFound404Exception("comment"); } if (string.IsNullOrWhiteSpace(model.Content)) { throw new IsRequiredException("content"); } if (model.Content.Length < 20) { throw new ContentIsInvalidException(); } // bind data comment.Content = model.Content; comment.UpdatedDate = DateTime.Now; await _postRepository.UpdateCommentAsync(comment); return(Ok(CommentDTO.GetFrom(comment))); }
public async Task <IActionResult> UpdateComment(int id, [FromBody] CommentUpdateModel model) { await _commentService.UpdateComment(id, _mapper.Map <CommentDTO>(model), Request.GetToken()); return(NoContent()); }
public Task <IResultModel> Update(CommentUpdateModel model) { return(_service.Update(model)); }
public async Task UpdateCommentAsync(CommentUpdateModel model) { var commentDTO = _mapper.Map <CommentDTO>(model); await _commentService.UpdateCommentAsync(commentDTO); }