[HttpPost]//TODO: move id to commentdto public IActionResult Comments(CommentDto commentDto) { commentDto.UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); _commentsService.CreateComment(commentDto); return(LocalRedirect($"~/question/page?userId={_commentsService.UserPageId(commentDto)}")); }
public async Task <ActionResult <CommentResponse> > CreateComment ( [FromServices] ICommentsService commentsService, [FromBody] CreateCommentRequest request ) { request.UserId = IdentityHelper.GetIdFromUser(User); return(await commentsService.CreateComment(request)); }
public ActionResult CreateComment(Comment comment) { try { var newComment = _commentsService.CreateComment(comment); return(Ok(newComment)); } catch (AlreadyExistsException ex) { return(Conflict(new AppError(ex.Message))); } }
public ActionResult CreateComment(InputCommentViewModel model) { if (!ModelState.IsValid) { TempData["NotificationError"] = "Sorry but something wrong. Please try angain later and don't forget content on comment"; return(Redirect(Request.UrlReferrer.ToString())); } var userId = User.Identity.GetUserId(); var comment = new Comment { Content = model.Content, UserId = userId, AnswerId = model.AnswerId }; m_Comments.CreateComment(comment); TempData["Notification"] = "You successfully comment."; return(Redirect(Request.UrlReferrer.ToString())); }
public async Task <IActionResult> CreateComment([FromBody] CreateCommentVm model) { model.UserId = this.CurrentUserId.Value; return(this.Ok(await _commentsService.CreateComment(model))); }
public Task Post([FromBody] CommentViewModel comment) { return(_commentsService.CreateComment(map(comment))); }