Uat_Study
he 2022-08-29 15:49:06 +08:00
parent 4620583aa5
commit 9835b31fda
1 changed files with 14 additions and 0 deletions

View File

@ -1505,6 +1505,20 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task<IResponseOutput> SubmitTableQuestion(SubmitTableQuestionInDto inDto)
{
var tableQuestionIds = inDto.AnswerList.Select(x => x.TableQuestionId).ToList();
var questions = await _readingTableQuestionTrialRepository.Where(x => tableQuestionIds.Contains(x.Id) && x.MaxRowCount != null).ToListAsync();
foreach (var item in questions)
{
var answer = inDto.AnswerList.Where(x => x.TableQuestionId == item.Id).Select(x => x.Answer).FirstOrDefault();
if ((await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id && x.Answer == answer).CountAsync()) > item.MaxRowCount.Value - 1)
{
throw new BusinessValidationFailedException($"问题{item.QuestionName}最大相同问题数为{item.MaxRowCount.Value},当前已超过!");
}
}
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
List<ReadingTableQuestionAnswer> answerList = inDto.AnswerList.Select(x => new ReadingTableQuestionAnswer()