diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 4e30ea8d0..4bd79f267 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -116,7 +116,7 @@ namespace IRaCIS.Core.Application.Service generateUser.Code = _userRepository.Select(t => t.Code).DefaultIfEmpty().Max() + 1; - generateUser.UserCode = AppSettings.GetCodeStr(generateUser.Code, nameof(User)); + generateUser.UserCode = AppSettings.GetCodeStr(generateUser.Code, nameof(User)); generateUser.UserName = generateUser.UserCode; @@ -165,7 +165,7 @@ namespace IRaCIS.Core.Application.Service else { return ResponseOutput.NotOk("人员信息不支持编辑,请删除后重新添加。"); - + } } @@ -176,6 +176,14 @@ namespace IRaCIS.Core.Application.Service [Authorize(Policy = IRaCISPolicy.PM_APM)] public async Task DeleteTrialExternalUser(Guid trialExternalUserId, bool isSystemUser, Guid systemUserId) { + var trialExternalUser = await _trialExternalUseRepository.FirstOrDefaultAsync(t => t.Id == trialExternalUserId); + + if (await _trialUserRepository.AnyAsync(t => t.TrialId == trialExternalUser.TrialId && t.Id == trialExternalUser.SystemUserId)) + { + return ResponseOutput.NotOk("当前用户已参与到项目,不允许删除"); + } + + var success = await _trialExternalUseRepository.BatchDeleteNoTrackingAsync(t => t.Id == trialExternalUserId); if (isSystemUser == false) @@ -200,7 +208,7 @@ namespace IRaCIS.Core.Application.Service var userId = userInfo.SystemUserId; await _mailVerificationService.ExternalUserJoinEmail(trialId, userId, sendEmail.BaseUrl, sendEmail.RouteUrl); - + //判断TrialUser中是否存在 不存在就插入 注意退出了,也不能再加进来 if (!await _trialUserRepository.AnyAsync(t => t.TrialId == trialId && t.UserId == userId, true))