public async Task <PagedResultDto <PhoneReplyRecord> > PhoneReplyRecordPage(PhoneReplyRecordIn PhoneReplyRecordInfo)
        {
            //初步过滤
            var query = _repository.GetAll().OrderByDescending(a => a.CreatedOn).Where(PhoneReplyRecordInfo.Expression);
            //获取总数
            var tasksCount = query.Count();
            //获取总数
            var totalpage            = tasksCount / PhoneReplyRecordInfo.MaxResultCount;
            var PhoneReplyRecordList = await query.PageBy(PhoneReplyRecordInfo.SkipTotal, PhoneReplyRecordInfo.MaxResultCount).ToListAsync();

            return(new PagedResultDto <PhoneReplyRecord>(tasksCount, PhoneReplyRecordList.MapTo <List <PhoneReplyRecord> >()));
        }
        public async Task <IList <ReplyDetail> > ReplyDetailList(PhoneReplyRecordIn ReplyDetailList)
        {
            var query     = _repository.GetAll();
            var querylist = from a in query
                            where !a.IsDelete && a.ConsultNumber == ReplyDetailList.ConsultNumber
                            select new ReplyDetail
            {
                ReplyId     = a.Id,
                CreatedBy   = a.CreatedBy,
                CreatedOn   = a.CreatedOn,
                ReplyType   = "answer",
                ConsultType = "Phone",
                Message     = a.RecordAddress,
                AnswerType  = "Phone",
            };

            return(await querylist.ToListAsync());
        }
        public async Task <ObjectResultModule> QualityControlManageDetail([FromBody] QualityControlManageIn QualityControlManage)
        {
            if (!Commons.CheckSecret(QualityControlManage.Secret))
            {
                this.ObjectResultModule.StatusCode = 422;
                this.ObjectResultModule.Message    = "Wrong Secret";
                this.ObjectResultModule.Object     = "";
                return(this.ObjectResultModule);
            }
            var userid         = _IabpSession.UserId > 0 ? (int)_IabpSession.UserId : 0;
            var qualitycontrol = await _QualityControlManageService.QualityControlManageByID(QualityControlManage.Id);

            var values = await _consultationService.YaeherConsultationByID(qualitycontrol.ConsultID);

            if (values == null)
            {
                return(new ObjectResultModule("", 204, "NoContent"));
            }
            var EvaluationIn = new ConsultationEvaluationIn();

            EvaluationIn.AndAlso(t => !t.IsDelete && t.ConsultNumber == values.ConsultNumber);
            var eva = await _consultationEvaluationService.ConsultationEvaluationList(EvaluationIn);

            ConsultationReplyIn consultationReplyIn = new ConsultationReplyIn();

            consultationReplyIn.ConsultNumber = values.ConsultNumber;
            var replys = await _consultationReplyService.ReplyDetailList(consultationReplyIn);

            PhoneReplyRecordIn phoneReplyRecordIn = new PhoneReplyRecordIn();

            phoneReplyRecordIn.ConsultNumber = values.ConsultNumber;
            var phonereplys = await _phoneReplyRecordService.ReplyDetailList(phoneReplyRecordIn);

            var AttachmentInfo = new AttachmentIn()
            {
                ConsultNumber = values.ConsultNumber
            };
            var Attachmentreply = await _attachmentServices.ReplyDetailList(AttachmentInfo);

            var doctor = JsonHelper.FromJson <YaeherDoctor>(values.DoctorJSON);
            var order  = await _orderManageService.OrderManageByconsultNumber(values.ConsultNumber);

            var serverid   = order.ServiceID;
            var UserResult = await _yaeherUser.YaeherUserByID(doctor.UserID);

            //var UserResult = JsonHelper.FromJson<APIResult<ResultModule<YaeherUser>>>(user);
            //if (UserResult == null || UserResult.result.item == null) { return new ObjectResultModule("", 204, "NoContent"); }

            var collect = await _collectConsultationService.CollectConsultationByExpression(t => !t.IsDelete && t.ConsultID == values.Id && t.CreatedBy == userid);

            //var where = new CollectConsultationIn();where.AndAlso(t => !t.IsDelete && t.ConsultID == values.Id && t.CreatedBy == userid);
            //var collect = await _collectConsultationService.CollectConsultationListAsync(where);

            if (phonereplys.Count > 0)
            {
                replys = replys.Union(phonereplys).ToList();
            }
            var questionatt = new List <ReplyDetail>();

            if (Attachmentreply != null && Attachmentreply.Count > 0)
            {
                foreach (var item in replys)
                {
                    var query = from a in Attachmentreply
                                where a.ReplyNumber == item.ReplyNumber
                                select new ConsultationFile
                    {
                        FileUrl        = a.Message,
                        FileName       = a.FileName,
                        FileSize       = a.FileSize,
                        MediaType      = a.Mediatype,
                        FileContentUrl = a.FileContentAddress,
                        FileTotalTime  = a.FileTotalTime,
                        Id             = a.Id,
                    };
                    item.ConsultationFile = query.ToList();
                    //var rep = Attachmentreply.result.item.(t => t.ReplyId == item.ReplyId).ToList();
                    //if (rep != null) { item.Message = rep; }
                }
                //replys = replys.Union(Attachmentreply.result.item).ToList();
                // replys = replys.Select(t => new ReplyDetail(t, Attachmentreply.result.item)).ToList();
                questionatt = Attachmentreply.Where(t => t.ConsultNumber == values.ConsultNumber && t.ServiceType == "consultation").ToList();
            }
            // var questionatt = Attachmentreply.Where(t => t.ConsultID == values.Id && t.ServiceType == "consultation").ToList();
            var param = new SystemParameterIn()
            {
                Type = "ConfigPar"
            };

            param.AndAlso(t => !t.IsDelete && t.SystemCode == "ConsultState");
            var paramlist = await _systemParameterService.ParameterList(param);

            var IIInesslabel = JsonHelper.FromJson <LableManage>(values.IIInessJSON);

            this.ObjectResultModule.Object = new QualityControlManageOutDetail(qualitycontrol, values, collect == null ? false : true, questionatt, replys, UserResult, eva, serverid, IIInesslabel.Id, paramlist);
            if (values == null)
            {
                this.ObjectResultModule.StatusCode = 404;
                this.ObjectResultModule.Message    = "NotFound";
                this.ObjectResultModule.Object     = "";
            }
            else
            {
                this.ObjectResultModule.StatusCode = 200;
                this.ObjectResultModule.Message    = "success";
            }
            #region 操作日志
            var CreateYaeherOperList = new YaeherOperList()
            {
                OperExplain = "QualityControlManageDetail",
                OperContent = JsonHelper.ToJson(QualityControlManage),
                OperType    = "QualityControlManageDetail",
                CreatedBy   = userid,
                CreatedOn   = DateTime.Now
            };
            var resultLog = await _yaeherOperListService.CreateYaeherOperList(CreateYaeherOperList);

            #endregion

            return(ObjectResultModule);
        }
        public async Task <IList <PhoneReplyRecord> > PhoneReplyRecordList(PhoneReplyRecordIn PhoneReplyRecordInfo)
        {
            var PhoneReplyRecords = await _repository.GetAllListAsync(PhoneReplyRecordInfo.Expression);

            return(PhoneReplyRecords.ToList());
        }