diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs index 288ebff2d..8d41dda22 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs @@ -246,8 +246,19 @@ namespace IRaCIS.Core.Application.Service await _doctorSummarizeRepository.InsertOrUpdateAsync(system, true); } } + + if (inDto.TrialId == null) + { + var systemCount = await _doctorSummarizeRepository.Where(x => x.DoctorId == inDto.DoctorId && x.TrialId == null).CountAsync(); + if (systemCount == 0) + { + inDto.IsMain = true; + } + } + if (inDto.TrialId == null && inDto.IsMain) { + await _doctorSummarizeRepository.BatchUpdateNoTrackingAsync(x => x.DoctorId == inDto.DoctorId && x.TrialId == null, x => new DoctorSummarize() {