Exemplo n.º 1
0
        public async Task <TzDataOutputDto <BlogArticleCommentReplyOutput> > Comment(BlogArticleCommentReplyInput input)
        {
            var comment = new BlogArticleComment
            {
                BlogArticleId = input.ArticleId,
                Description   = input.Content,
                ReviewerId    = Guid.Parse(TzUser.Id)
            };
            var r = await _blogArticleComment.AddOrEditAndSaveAsyn(comment);

            return(new TzDataOutputDto <BlogArticleCommentReplyOutput>
            {
                State = r,
                Code = HttpContext.Response.StatusCode,
                Msg = r ? "" : "评论失败!",
                Data = !r ? null : new BlogArticleCommentReplyOutput
                {
                    Id = comment.Id,
                    Content = comment.Description,
                    CommentReplyUser = await GetUserDtoByUser(await GetUserByName(adminName)),
                    CommentUser = await GetUserDtoById(comment.ReviewerId),
                    CreateTime = comment.CreateTime
                }
            });
        }
Exemplo n.º 2
0
        public async Task <TzDataOutputDto <BlogArticleCommentReplyOutput> > Reply(BlogArticleCommentReplyInput input)
        {
            bool   r        = false;
            string message  = string.Empty;
            var    reply    = new BlogArticleReply();
            var    currUser = TzUser;

            if (currUser.Id.Equals(input.CommentReplyUserId.Value.ToString()))
            {
                message = "您不能回复自己!";
            }
            else
            {
                reply = new BlogArticleReply
                {
                    CommentId           = input.CommentId,
                    ReceiveRespondentId = input.CommentReplyUserId.Value,
                    RespondentId        = Guid.Parse(currUser.Id),
                    Description         = input.Content
                };
                r = await _blogArticleReply.AddOrEditAndSaveAsyn(reply);

                if (r)
                {
                    //await _tzNotification.Send(new NotificationSendInput
                    //{
                    //    ObjectId = reply.Id,
                    //    Content = input.Content,
                    //    ReceiverId = reply.ReceiveRespondentId,
                    //    Source = TzNotificationSource.ArticleReply
                    //});
                }
                message = "回复失败!";
            }
            return(new TzDataOutputDto <BlogArticleCommentReplyOutput>
            {
                State = r,
                Code = HttpContext.Response.StatusCode,
                Msg = r ? "" : message,
                Data = !r ? null : new BlogArticleCommentReplyOutput
                {
                    Id = reply.Id,
                    Content = reply.Description,
                    CommentReplyUser = await GetUserDtoById(reply.RespondentId),
                    CommentUser = await GetUserDtoById(reply.ReceiveRespondentId),
                    CreateTime = reply.CreateTime
                }
            });
        }