Пример #1
0
        [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)}"));
        }
Пример #2
0
 public async Task <ActionResult <CommentResponse> > CreateComment
 (
     [FromServices] ICommentsService commentsService,
     [FromBody] CreateCommentRequest request
 )
 {
     request.UserId = IdentityHelper.GetIdFromUser(User);
     return(await commentsService.CreateComment(request));
 }
Пример #3
0
 public ActionResult CreateComment(Comment comment)
 {
     try
     {
         var newComment = _commentsService.CreateComment(comment);
         return(Ok(newComment));
     }
     catch (AlreadyExistsException ex)
     {
         return(Conflict(new AppError(ex.Message)));
     }
 }
Пример #4
0
        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()));
        }
Пример #5
0
 public async Task <IActionResult> CreateComment([FromBody] CreateCommentVm model)
 {
     model.UserId = this.CurrentUserId.Value;
     return(this.Ok(await _commentsService.CreateComment(model)));
 }
Пример #6
0
 public Task Post([FromBody] CommentViewModel comment)
 {
     return(_commentsService.CreateComment(map(comment)));
 }