public IActionResult UpdateComment(int commentId, int userId, CommentForUpdateDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(Messages.ModelNullOrEmpty));
            }
            var postComment = _postCommentService.GetById(commentId);

            if (!postComment.Success)
            {
                return(BadRequest(postComment.Message));
            }

            if (postComment.Data.UserId != userId)
            {
                return(BadRequest(Messages.YouUnauthorizeChangeThisComment));
            }

            postComment.Data.Comment = model.comment;
            var result = _postCommentService.Update(postComment.Data);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
예제 #2
0
        public IHttpActionResult UpdateComment(int commentId, int userId, CommentForUpdateDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("girdiğiniz bilgiler eksik yahut hatalı"));
            }

            var postComment = _commentRepository.Get(p => p.PostCommentId == commentId);

            if (postComment == null)
            {
                return(BadRequest("böyle bir yorum henüz girilmemiş"));
            }


            if (postComment.UserId != userId)
            {
                return(Content(HttpStatusCode.Unauthorized, "Bu yorumu güncellemeye yetkiniz yok"));
            }


            postComment.Comment = model.comment;
            _commentRepository.Update(postComment);

            return(Ok());
        }