diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs index ee2c417d2..63d4b8d5f 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs @@ -1574,7 +1574,14 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public class GetCalculateQuestionsOutDto: ReadingQuestionSystemView { - public List TableQuestions { get; set; } + public List TableQuestions { get; set; } + } + + + public class GetSystemCalculateQuestionsOutDto : ReadingQuestionSystemView + { + + public List TableQuestions { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs index e67a39f2e..63d36a437 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs @@ -88,7 +88,7 @@ namespace IRaCIS.Core.Application.Service /// /// [HttpPost] - public async Task> GetCalculateQuestions(GetCalculateQuestionsInDto inDto) + public async Task<(List,bool)> GetCalculateQuestions(GetCalculateQuestionsInDto inDto) { var result = await _readingQuestionTrialRepository @@ -98,7 +98,15 @@ namespace IRaCIS.Core.Application.Service .OrderBy(x => x.ShowOrder) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - return result; + + var tablequestion=await _readingTableQuestionTrialRepository.Where(x=>x.TrialCriterionId==inDto.TrialCriterionId).ToListAsync(); + + result.ForEach(x => + { + x.TableQuestions = tablequestion.Where(y => y.ReadingQuestionId == x.Id).ToList(); + }); + + return (result,true); } /// @@ -107,7 +115,7 @@ namespace IRaCIS.Core.Application.Service /// /// [HttpPost] - public async Task> GetSystemCalculateQuestions(GetSystemCalculateQuestionsInDto inDto) + public async Task> GetSystemCalculateQuestions(GetSystemCalculateQuestionsInDto inDto) { var result = await _readingQuestionSystemRepository @@ -115,7 +123,16 @@ namespace IRaCIS.Core.Application.Service .WhereIf(!inDto.Type.IsNullOrEmpty(), x => x.Type == inDto.Type) .WhereIf(inDto.TypeList.Count() > 0, x => inDto.TypeList.Contains(x.Type)) .OrderBy(x => x.ShowOrder) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync() ; + .ProjectTo(_mapper.ConfigurationProvider).ToListAsync() ; + + + var tablequestion = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == inDto.SystemCriterionId).ToListAsync(); + + result.ForEach(x => + { + + x.TableQuestions = tablequestion.Where(y => y.ReadingQuestionId == x.Id).ToList(); + }); return result; } diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 3f47c883b..3a55897d4 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -225,12 +225,10 @@ namespace IRaCIS.Core.Application.Service .ForMember(dest => dest.CreateUser, opt => opt.Ignore()) .ForMember(d => d.DependShowOrder, u => u.MapFrom(s => s.DependParentQuestion.ShowOrder)); - CreateMap() - .ForMember(d => d.TableQuestions, u => u.MapFrom(s => s.ReadingTableQuestionTrialList)); + CreateMap(); - CreateMap() - .ForMember(d => d.TableQuestions, u => u.MapFrom(s => s.ReadingTableQuestionTrialList)); + CreateMap(); CreateMap() .ForMember(dest => dest.CreateUser, opt => opt.Ignore())