Ejemplo n.º 1
0
        public async Task <Response <object> > Publish(QAPublishInput input)
        {
            await _IQAPublishApp.Publish(input);

            return(new Response <object> {
                Status = 1, Msg = "发布成功"
            });
        }
Ejemplo n.º 2
0
        public async Task <Response <object> > SaveQuestion(QAPublishInput input)
        {
            var postGuid = await _IQAPublishApp.QASave(input);

            return(new Response <object> {
                Status = 1, Msg = "插入成功", Data = new { postGuid }
            });
        }
Ejemplo n.º 3
0
        public async Task <Response <object> > Reply(QAPublishInput input)
        {
            await _IQAPublishApp.Reply(input);

            await _IQAPublishApp.SetState(input.Guid, 2);

            return(new Response <object> {
                Status = 1, Msg = "", Data = "OK"
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// QA问题发布
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task Publish(QAPublishInput input)
        {
            var entity = _qpRepository.Get(o => o.Guid == input.Guid).First();

            entity.QuestionCategory = input.QuestionCategory;
            entity.BelongDepartment = input.BelongDepartment;
            entity.PostTime         = DateTime.Now;
            await _qpRepository.UpdateAsync(entity);

            await _mongo.UpdateAsync <Post>(o => o.PostGuid == input.Guid, new { Category = input.QuestionCategory });

            await this.SetState(input.Guid, 1);

            _qpRepository.SaveChanges();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// QA问题回复
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task Reply(QAPublishInput input)
        {
            Reply reply = new Reply
            {
                Content    = input.Content,
                CreateTime = DateTime.Now,
                PostGuid   = input.Guid,
                JobNum     = "10038243",
                Author     = "杨帆",
                Attachment = input.Attachment
            };
            var result = await _mongo.InsertAsync <Reply>(reply);

            await this.SetState(input.Guid, 2, o => o.State < 3);

            _qpRepository.SaveChanges();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 保存问题
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <string> QASave(QAPublishInput input)
        {
            var postGuid = "";

            if (string.IsNullOrEmpty(input.Guid))
            {
                var entity = new QuestionsPublish();
                entity.Title      = input.Title;
                entity.CreateTime = DateTime.Now;
                entity.State      = 0;
                entity.Guid       = input.TempGuid;
                entity.JobNum     = "xxx";
                entity.Author     = "xxxname";
                postGuid          = entity.Guid;
                await _qpRepository.InsertAsync(entity);

                Post post = new Post
                {
                    Tag = new List <string> {
                        "问答"
                    },
                    Title      = entity.Title,
                    Content    = input.Content,
                    CreateTime = DateTime.Now,
                    PostGuid   = postGuid,
                    Locked     = 2,
                    Type       = 1
                };
                var result = _mongo.InsertAsync <Post>(post);
            }
            else//修改
            {
                var entity = _qpRepository.Get(o => o.Guid == input.Guid).First();
                postGuid     = entity.Guid;
                entity.Title = input.Title;
                await _qpRepository.UpdateAsync(entity);

                var mongoContent = _mongo.QueryAsync <Post>(o => o.PostGuid == postGuid && o.Type == 1).Result.ToList();
                if (mongoContent.Count() > 0)
                {
                    mongoContent.First().Content = input.Content;
                    await _mongo.UpdateAsync <Post>(mongoContent.First());
                }
                else
                {
                    Post post = new Post
                    {
                        Tag = new List <string> {
                            "问答"
                        },
                        Title      = entity.Title,
                        Content    = input.Content,
                        CreateTime = DateTime.Now,
                        PostGuid   = postGuid,
                        Locked     = 2,
                        Type       = 1
                    };
                    var result = _mongo.InsertAsync <Post>(post);
                }
            }
            _qpRepository.SaveChanges();
            return(postGuid);
        }