Uat_Study
he 2022-08-18 14:18:25 +08:00
parent 81a0a7d02d
commit d461ceaa21
2 changed files with 76 additions and 51 deletions

View File

@ -13,6 +13,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public Guid SourceSystemCriterionId { get; set; }
public Guid NewSystemCriterionId { get; set; }
public bool IsCopyQuestion { get; set; }
}

View File

@ -34,6 +34,7 @@ namespace IRaCIS.Application.Services
private readonly IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository;
private readonly IRepository<ReadingCriterionPage> _readingCriterionPageRepository;
private readonly IRepository<Trial> _trialRepository;
private readonly IRepository<OrganInfo> _organInfoRepository;
private readonly IRepository<ReadingTableQuestionSystem> _readingTableQuestionSystemRepository;
private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswer;
private readonly IRepository<PreviousPDF> _previousPDFRepository;
@ -50,6 +51,7 @@ namespace IRaCIS.Application.Services
IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository,
IRepository<ReadingCriterionPage> readingCriterionPageRepository,
IRepository<Trial> trialRepository,
IRepository<OrganInfo> organInfoRepository,
IRepository<ReadingTableQuestionSystem> readingTableQuestionSystemRepository,
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswer,
IRepository<PreviousPDF> previousPDFRepository
@ -66,6 +68,7 @@ namespace IRaCIS.Application.Services
this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository;
this._readingCriterionPageRepository = readingCriterionPageRepository;
this._trialRepository = trialRepository;
this._organInfoRepository = organInfoRepository;
this._readingTableQuestionSystemRepository = readingTableQuestionSystemRepository;
this._readingTaskQuestionAnswer = readingTaskQuestionAnswer;
this._previousPDFRepository = previousPDFRepository;
@ -78,6 +81,8 @@ namespace IRaCIS.Application.Services
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> CopySystemCriterionData(CopySystemCriterionDataInDto inDto)
{
if (inDto.IsCopyQuestion)
{
var newSystemQuestionList = await _readingQuestionSystemRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.SourceSystemCriterionId)
.ProjectTo<ReadingQuestionSystemData>(_mapper.ConfigurationProvider).ToListAsync();
@ -113,7 +118,7 @@ namespace IRaCIS.Application.Services
foreach (var x in newSystemTableQuestionList)
{
var tableQuestion = x.Clone();
tableQuestion.SystemCriterionId =inDto.NewSystemCriterionId;
tableQuestion.SystemCriterionId = inDto.NewSystemCriterionId;
tableQuestion.Id = NewId.NextGuid();
if (tableQuestion.ParentId != null)
{
@ -132,6 +137,24 @@ namespace IRaCIS.Application.Services
await _readingTableQuestionSystemRepository.BatchDeleteNoTrackingAsync(x => x.SystemCriterionId == inDto.NewSystemCriterionId);
await _readingTableQuestionSystemRepository.AddRangeAsync(needAddTableDatas);
#endregion
}
else
{
var organData = await _organInfoRepository.Where(x => x.SystemCriterionId == inDto.SourceSystemCriterionId).ToListAsync();
organData.ForEach(x => {
x.Id = NewId.NextGuid();
x.SystemCriterionId = inDto.NewSystemCriterionId;
});
await _organInfoRepository.BatchDeleteNoTrackingAsync(x => x.SystemCriterionId == inDto.NewSystemCriterionId);
await _organInfoRepository.AddRangeAsync(organData);
}
await _readingTableQuestionSystemRepository.SaveChangesAsync();
return ResponseOutput.Ok();
}