From 8c093427e25eeb5103682563fb789cfac4ffb31a Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Thu, 11 Aug 2022 16:01:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reading/ReadingMedicineQuestionService.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingMedicineQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingMedicineQuestionService.cs index db9e868e5..3ad41540a 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingMedicineQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingMedicineQuestionService.cs @@ -61,11 +61,11 @@ namespace IRaCIS.Core.Application.Service { var existsQuery = _readingMedicineSystemQuestionRepository .WhereIf(inDto.Id != null, x => x.Id != inDto.Id) - .Where(x => x.QuestionName == inDto.QuestionName ||x.ShowOrder == inDto.ShowOrder); + .Where(x =>x.ShowOrder == inDto.ShowOrder); if (await existsQuery.AnyAsync()) { - return ResponseOutput.NotOk("当前问题名称或序号存在重复"); + return ResponseOutput.NotOk("当前问题序号存在重复"); } var entity = await _readingMedicineSystemQuestionRepository.InsertOrUpdateAsync(inDto); await _readingMedicineSystemQuestionRepository.SaveChangesAsync(); @@ -162,11 +162,11 @@ namespace IRaCIS.Core.Application.Service var existsQuery = _readingMedicineTrialQuestionRepository .WhereIf(inDto.Id != null, x => x.Id != inDto.Id) .Where(x => x.TrialId==inDto.TrialId) - .Where(x => x.QuestionName == inDto.QuestionName || x.ShowOrder == inDto.ShowOrder); + .Where(x => x.ShowOrder == inDto.ShowOrder); if (await existsQuery.AnyAsync()) { - return ResponseOutput.NotOk("当前问题名称或序号存在重复"); + return ResponseOutput.NotOk("当前问题序号存在重复"); } var entity = await _readingMedicineTrialQuestionRepository.InsertOrUpdateAsync(inDto); await _readingMedicineTrialQuestionRepository.SaveChangesAsync(); @@ -213,10 +213,14 @@ namespace IRaCIS.Core.Application.Service { // 直接写?? var systemList = await _readingMedicineSystemQuestionRepository.Where(x => inDto.SystemQuestionIds.Contains(x.Id)).ToListAsync(); - var needList= systemList.Select(x => new ReadingMedicineTrialQuestion() + + var maxOrder = await _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId).OrderByDescending(x => x.ShowOrder).Select(x => x.ShowOrder).FirstOrDefaultAsync(); + + + var needList= systemList.Select(x => new ReadingMedicineTrialQuestion() { Id = NewId.NextGuid(), - ShowOrder = x.ShowOrder, + ShowOrder = maxOrder++, IsEnable = x.IsEnable, IsRequired = x.IsRequired, QuestionName = x.QuestionName, @@ -226,6 +230,8 @@ namespace IRaCIS.Core.Application.Service TrialId=inDto.TrialId, }).ToList(); + + await _readingMedicineTrialQuestionRepository.AddRangeAsync(needList); var result = await _readingMedicineTrialQuestionRepository.SaveChangesAsync(); return ResponseOutput.Result(result);