public async Task AddComment(AddCommentRequest request) { DateTime now = DateTime.Now; User user = _userRepository.GetUserByName(request.Author); string avatar = user.UserAvatar; Comment comment = new Comment { PostId = request.PostId, Body = request.Body, Author = user.Login, AuthorAvatar = avatar, CreateDate = now }; await _repository.AddComment(comment); }
public IActionResult AddCommentToReview(int id, [FromBody] AddCommentModel model) { var cmt = _mapper.Map <Comment>(model); cmt.UserId = int.Parse(User.Identity.Name); cmt.ReviewId = id; try { _forumService.AddComment(cmt); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public ActionResult AddReply(Comment com) { _forumRepository.AddComment(com); return(RedirectToAction("Post", com.PostId)); }