Пример #1
0
        public async Task <IActionResult> Reply(Guid commentId, string replyContent, [FromServices] LinkGenerator linkGenerator)
        {
            var response = await _commentService.AddReply(
                commentId,
                replyContent,
                HttpContext.Connection.RemoteIpAddress.ToString(),
                GetUserAgent());

            if (!response.IsSuccess)
            {
                Response.StatusCode = StatusCodes.Status500InternalServerError;
                return(Json(response));
            }

            if (_blogConfig.EmailSettings.SendEmailOnCommentReply)
            {
                var postLink = GetPostUrl(linkGenerator, response.Item.PubDateUtc, response.Item.Slug);
                _ = Task.Run(async() =>
                {
                    await _notificationClient.SendCommentReplyNotificationAsync(response.Item, postLink);
                });
            }

            return(Json(response.Item));
        }
Пример #2
0
        public async Task <IActionResult> Reply(ReplyRequest request, [FromServices] LinkGenerator linkGenerator)
        {
            if (request.CommentId == Guid.Empty)
            {
                ModelState.AddModelError(nameof(request.CommentId), "value is empty");
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_blogConfig.ContentSettings.EnableComments)
            {
                return(Forbid());
            }

            var reply = await _commentService.AddReply(request.CommentId, request.ReplyContent);

            if (_blogConfig.NotificationSettings.SendEmailOnCommentReply && !string.IsNullOrWhiteSpace(reply.Email))
            {
                var postLink = GetPostUrl(linkGenerator, reply.PubDateUtc, reply.Slug);
                _ = Task.Run(async() =>
                {
                    await _notificationClient.NotifyCommentReplyAsync(reply, postLink);
                });
            }

            return(Ok(reply));
        }
Пример #3
0
        public ActionResult AddReply(string reply, int parentId)
        {
            if (reply.Length > 0)
            {
                ICommentService commentService = new CommentService();
                IUserService    userService    = new UserService();
                string          userId         = User.Identity.GetUserId();
                var             pub            = ctx.Publications.Where(p => p.PublicationId == ctx.Comments.Where(c => c.CommentId == parentId).FirstOrDefault().PublicationID).FirstOrDefault();

                commentService.AddReply(reply, parentId, userId);
                return(Redirect("Open/" + pub.PublicationId.ToString()));
            }
            else
            {
                return(View("Open"));
            }
        }
Пример #4
0
        public async Task <IActionResult> Reply(Guid commentId, string replyContent, [FromServices] LinkGenerator linkGenerator)
        {
            if (!_blogConfig.ContentSettings.EnableComments)
            {
                return(Forbid());
            }

            var reply = await _commentService.AddReply(commentId, replyContent);

            if (_blogConfig.NotificationSettings.SendEmailOnCommentReply && !string.IsNullOrWhiteSpace(reply.Email))
            {
                var postLink = GetPostUrl(linkGenerator, reply.PubDateUtc, reply.Slug);
                _ = Task.Run(async() =>
                {
                    await _notificationClient.NotifyCommentReplyAsync(reply, postLink);
                });
            }

            return(Json(reply));
        }
Пример #5
0
        public IActionResult AddReply(string commentId, string text)
        {
            string UserFullName = ClaimUtility.GetUserFullName(HttpContext.User);

            return(Json(_commentService.AddReply(commentId, UserFullName, text)));
        }