예제 #1
0
 protected void ReferenceRep(BZReplyDto reply)
 {
     if (User == null)
     {
         return;
     }
     else
     {
         MBZReplyDto = new NewReplyModel {
             Content = reply.Content
         };
         StateHasChanged();
     }
 }
예제 #2
0
        public async Task <IActionResult> Add([FromBody] BZReplyDto dto)
        {
            var reply           = _mapper.Map <BZReplyModel>(dto);
            var topicRepostory  = _unitOfWork.GetRepository <BZTopicModel>(true);
            var replyRepository = _unitOfWork.GetRepository <BZReplyModel>();
            var userRepository  = _unitOfWork.GetRepository <BZUserModel>();
            var topic           = topicRepostory.GetFirstOrDefault(p => p.Id == dto.TopicId);

            if (topic != null)
            {
                var addResult = await _unitOfWork.CommitWithTransactionAsync(async() =>
                {
                    var result = await replyRepository.InsertAsync(reply);
                    if (!string.IsNullOrWhiteSpace(result.Entity.Id))
                    {
                        _cacheService.Remove(nameof(BZReplyModel));
                        topic.ReplyCount++;
                        topicRepostory.Update(topic);
                        _cacheService.Remove(nameof(BZTopicModel));
                    }
                });

                if (addResult)
                {
                    var Topicuser = await userRepository.FindAsync(topic.CreatorId);

                    if (Topicuser != null && !string.IsNullOrWhiteSpace(Topicuser.Email))
                    {
                        messageService.SendEmailToTopicCreatorAsync(Topicuser?.Email, topic.Title, topic.Id);
                    }
                    var ReplyUser = await userRepository.FindAsync(reply.CreatorId);

                    if (ReplyUser != null && (!string.IsNullOrWhiteSpace(ReplyUser.QQ) || !string.IsNullOrWhiteSpace(Topicuser.QQ)))
                    {
                        if (ReplyUser.QQ != Topicuser.QQ)//自己回复自己的,不通知
                        {
                            cQService.SendGroupMessageToUser(topic.Id, topic.Title, Topicuser.QQ, ReplyUser.QQ);
                        }
                    }
                }
                return(Ok());
            }
            return(new BadRequestResponse("帖子不存在"));
        }
예제 #3
0
        private async Task NewReply(NewReplyModel model, string UserId)
        {
            if (string.IsNullOrWhiteSpace(model.Content))
            {
                form.Toast("还是写点什么吧");
                return;
            }

            if (Topic is null)
            {
                ToastError($"主贴不存在或已被删除");
                NavigationManager.NavigateTo("/");
                return;
            }

            BZReplyDto bZReplyDto = new BZReplyDto()
            {
                Content        = model.Content,
                UserId         = Topic.CreatorId,
                Favor          = 0,
                CreateDate     = DateTime.Now,
                LastModifyDate = DateTime.Now,
                Status         = 0,
                TopicId        = Topic.Id,
                CreatorId      = UserId
            };

            await WithFullScreenLoading(async() =>
            {
                var addResult = await NetService.AddReply(bZReplyDto);
                if (addResult.IsSuccess)
                {
                    NavigationManager.NavigateTo(NavigationManager.Uri, true);//跳转到+"&golast=1"
                }
                else
                {
                    ToastError("回复失败");
                    return;
                }
            });
        }
예제 #4
0
 protected async Task EditReply(BZReplyDto ReplyModel)
 {
     if (ReplyModel.ShoudEdit)
     {
         if (ReplyModel.OriginalContent != ReplyModel.Content)
         {
             await WithFullScreenLoading(async() =>
             {
                 var result = await NetService.UpdateReply(new BZReplyDto()
                 {
                     Id = ReplyModel.Id, Content = ReplyModel.Content, LastModifierId = User.Id
                 });
                 MessageService.Show(result.IsSuccess ? "编辑成功" : "编辑失败", result.IsSuccess ? MessageType.Success : MessageType.Error);
                 if (result != null && result.IsSuccess)
                 {
                     await LoadData();
                 }
             });
         }
     }
     ReplyModel.ShoudEdit = !ReplyModel.ShoudEdit;
 }
예제 #5
0
        /// <summary>
        /// 新增回帖
        /// </summary>
        /// <param name="topicId"></param>
        /// <returns></returns>
        public async Task <BaseResponse> AddReply(BZReplyDto bZReplyDto)
        {
            HttpContent httpContent = bZReplyDto.BuildHttpContent();

            return(await HttpRequestWithValidate($"api/client/Reply/Add", HttpMethod.Post, httpContent));
        }
예제 #6
0
 /// <summary>
 /// 修改回贴内容
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public async Task <BaseResponse> UpdateReply(BZReplyDto dto)
 {
     return(await HttpRequestWithValidate($"api/client/reply/UpdateContent", HttpMethod.Patch, dto.BuildHttpContent()));
 }