diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index c3993c41a..4d5ff7563 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -89,16 +89,22 @@ namespace IRaCIS.Application.Services if (subjectId != null) { - var subjectList = await _subjectRepository.Where(t => t.TrialId == trialId) + var subjectList =await _subjectRepository.Where(t => t.TrialId == trialId) .Where(t => t.SubjectDoctorList.Any(t => t.DoctorUserId == _userInfo.Id)) - .Select((s,index) => new SubjectTask() + .Select(s => new SubjectTask() { - Index=index, SubjectId = s.Id, UnReadTaskCount = s.SubjectVisitTaskList.Count(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.DoctorUserId == _userInfo.Id), }).ToListAsync(); + subjectList = subjectList.Select((x, index) => new SubjectTask() + { + Index = index, + SubjectId = x.SubjectId, + UnReadTaskCount = x.UnReadTaskCount, + }).ToList(); - var subjectIndex = subjectList.Where(x => x.SubjectId == subjectId).Select(x=>x.Index).FirstOrDefault(); + + var subjectIndex = subjectList.Where(x => x.SubjectId == subjectId).Select(x=>x.Index).FirstOrDefault(); var newSubjectId = subjectList.Where(x => x.Index >= subjectIndex && x.UnReadTaskCount != 0).Select(x=>x.SubjectId).FirstOrDefault(); task = await _visitTaskRepository.Where(x => x.TrialId == trialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == newSubjectId && x.DoctorUserId == _userInfo.Id).Select(x => new GetReadingTaskDto() {