示例#1
0
        /// <summary>
        /// 发表帖子
        /// </summary>
        /// <param name="bZTopicDto"></param>
        /// <returns></returns>
        public async Task <BaseResponse> AddTopic(BZTopicDto bZTopicDto, bool Notice)
        {
            HttpContent httpContent = bZTopicDto.BuildHttpContent();
            var         notice      = Notice ? 1 : 0;

            return(await HttpRequestWithValidate($"api/client/Topic/Add/{notice}", HttpMethod.Post, httpContent));
        }
        /// <summary>
        /// 发表帖子
        /// </summary>
        /// <param name="bZTopicDto"></param>
        /// <returns></returns>
        internal async Task <BaseResponse> NewTopic(BZTopicDto bZTopicDto)
        {
            if (!isSupper)
            {
                return(Unauthorized);
            }

            return(await httpClient.PostWithJsonResultAsync("api/Topic/Add", bZTopicDto.BuildHttpContent()));
        }
        public async Task <IActionResult> Add([FromBody] BZTopicDto dto, [FromRoute] int Notice = 0)
        {
            var topicModel = _mapper.Map <BZTopicModel>(dto);
            var model      = await _bZTopicRepository.InsertAsync(topicModel);

            _cacheService.Remove(nameof(BZTopicModel));
            if (dto.Category == 0 || Notice == 1)
            {
                messageService.SendEmailToManagerForAnswerAsync(model.Entity.Id);

                cQService.SendGroupMessageToManager(model.Entity.Id, model.Entity.Title);
            }
            return(Ok(model.Entity.Id));
        }
        public IActionResult UpdateContent([FromBody] BZTopicDto Dto)
        {
            if (string.IsNullOrWhiteSpace(Dto.Id))
            {
                return(new BadRequestResponse("id is error"));
            }
            var topic = _bZTopicRepository.Find(Dto.Id);

            if (topic == null)
            {
                return(new BadRequestResponse("no this topic"));
            }
            topic.Content        = Dto.Content;
            topic.Title          = Dto.Title;
            topic.LastModifyDate = DateTime.Now;
            _bZTopicRepository.Update(topic);
            _cacheService.Remove(nameof(BZTopicModel));
            return(Ok());
        }
        public IActionResult UpdateContent([FromBody] BZTopicDto Dto)
        {
            if (string.IsNullOrWhiteSpace(Dto.Id))
            {
                return(new BadRequestResponse("id is error"));
            }
            var reply = _replyRepository.Find(Dto.Id);

            if (reply == null)
            {
                return(new BadRequestResponse("no this error"));
            }
            reply.Content        = Dto.Content;
            reply.LastModifyDate = DateTime.Now;
            reply.LastModifierId = Dto.LastModifierId;
            _replyRepository.Update(reply);
            _cacheService.Remove(nameof(BZReplyModel));
            return(Ok());
        }
示例#6
0
        private async Task AddTopic(NewTopicModel newTopicModel)
        {
            var User = await GetUser();

            BZTopicDto bZTopicDto = new BZTopicDto()
            {
                Content   = newTopicModel.Content,
                Title     = newTopicModel.Title,
                Category  = (int)newTopicModel.Category,
                CreatorId = User.Id,
                //VersionId = bZVersions.FirstOrDefault(p => p.VerNo == newTopicModel.VerNo)?.Id,
                LastModifyDate = DateTime.Now,
                CreateDate     = DateTime.Now,
                Good           = 0,
                Hot            = 0,
                ReplyCount     = 0,
                Status         = 0,
                Top            = 0,
            };

            await WithFullScreenLoading(async() =>
            {
                var result = await NetService.AddTopic(bZTopicDto, newTopicModel.Notice);

                if (result.IsSuccess)
                {
                    ToastSuccess("发布成功");
                    await Task.Delay(100);
                    NavigationManager.NavigateTo($"/topic/{result.Data}");
                }
                else
                {
                    ToastError($"发布失败{result.Message}");
                }
            });
        }
示例#7
0
 /// <summary>
 /// 修改主贴内容
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public async Task <BaseResponse> UpdateTopic(BZTopicDto dto)
 {
     return(await HttpRequestWithValidate($"api/client/topic/UpdateContent", HttpMethod.Patch, dto.BuildHttpContent()));
 }