diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs index d4c1f6e2a..ee2c417d2 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingQuestionViewModel.cs @@ -1571,13 +1571,10 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public bool IsJudgeQuestion { get; set; } } - public class GetCalculateQuestionsOutDto + public class GetCalculateQuestionsOutDto: ReadingQuestionSystemView { - public Guid QuestionId { get; set; } - public string QuestionName { get; set; } - - public List TableQuestions { get; set; } + 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 8822739ac..e67a39f2e 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs @@ -96,33 +96,7 @@ 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) - .Select(x => new GetCalculateQuestionsOutDto - () - { - QuestionId = x.Id, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us) - - }).ToListAsync(); - - var tablequestion = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == inDto.TrialCriterionId && x.Type == "number").Select(x => - new - { - QuestionId = x.Id, - x.ReadingQuestionId, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us) - }).ToListAsync(); - - - result.ForEach(x => - { - x.TableQuestions = tablequestion.Where(y => x.QuestionId == y.ReadingQuestionId).Select(y => new CalculateQuestion() - { - - QuestionId = y.QuestionId, - QuestionName = y.QuestionName - - }).ToList(); - }); + .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); return result; } @@ -141,33 +115,7 @@ 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) - .Select(x => new GetCalculateQuestionsOutDto - () - { - QuestionId = x.Id, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us) - - }).ToListAsync(); - - var tablequestion = await _readingTableQuestionSystemRepository.Where(x => x.SystemCriterionId == inDto.SystemCriterionId && x.Type == "number").Select(x => - new - { - QuestionId = x.Id, - x.ReadingQuestionId, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us) - }).ToListAsync(); - - - result.ForEach(x => - { - x.TableQuestions = tablequestion.Where(y => x.QuestionId == y.ReadingQuestionId).Select(y => new CalculateQuestion() - { - - QuestionId = y.QuestionId, - QuestionName = y.QuestionName - - }).ToList(); - }); + .ProjectTo(_mapper.ConfigurationProvider).ToListAsync() ; return result; } diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 77d7ac97a..3f47c883b 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -220,6 +220,18 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.DependShowOrder, u => u.MapFrom(s => s.DependParentQuestion.ShowOrder)); + + CreateMap() + .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() + .ForMember(d => d.TableQuestions, u => u.MapFrom(s => s.ReadingTableQuestionTrialList)); + CreateMap() .ForMember(dest => dest.CreateUser, opt => opt.Ignore()) .ForMember(d => d.DependShowOrder, u => u.MapFrom(s => s.DependParentQuestion.ShowOrder)) diff --git a/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingQuestionSystem.cs b/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingQuestionSystem.cs index a27dae89d..12055cdb3 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingQuestionSystem.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingQuestionSystem.cs @@ -15,6 +15,9 @@ public class ReadingQuestionSystem : BaseAddAuditEntity [ForeignKey("ReadingQuestionCriterionSystemId")] public ReadingQuestionCriterionSystem ReadingQuestionCriterionSystem { get; set; } + [JsonIgnore] + public List ReadingTableQuestionTrialList { get; set; } + [JsonIgnore] [ForeignKey("ParentId")] public ReadingQuestionSystem ParentReadingQuestionSystem { get; set; } diff --git a/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionSystem.cs b/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionSystem.cs index 9ccfca6c8..64f81ca2c 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionSystem.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingCriterionQuestion/ReadingTableQuestionSystem.cs @@ -12,6 +12,11 @@ public class ReadingTableQuestionSystem : BaseAddAuditEntity [JsonIgnore] public ReadingTableQuestionSystem DependParentQuestion { get; set; } + + [JsonIgnore] + [ForeignKey("ReadingQuestionId")] + public ReadingQuestionSystem ReadingQuestionSystem { get; set; } + [NotMapped] public List ParentTriggerValueList {