diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 6a130b053..a86c5b2a6 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -595,13 +595,24 @@ namespace IRaCIS.Core.Application.Service - await _userRoleRepository.SaveChangesAsync(); } else { - sysUserInfo = (await _identityUserRepository.Where(t => t.UserRoleList.Any(t => t.DoctorId == doctorId || t.IdentityUser.EMail == doctor.EMail)).Include(t => t.UserRoleList).FirstOrDefaultAsync()).IfNullThrowException(); + sysUserInfo = (await _identityUserRepository.Where(t => t.UserRoleList.Any(t => t.DoctorId == doctorId || t.IdentityUser.EMail == doctor.EMail), true).Include(t => t.UserRoleList).FirstOrDefaultAsync()).IfNullThrowException(); + + //不存在该角色,那么就加入该角色 + if (!sysUserInfo.UserRoleList.Any(t => t.UserTypeId == userType.Id)) + { + sysUserInfo.UserRoleList.Add(new UserRole() { DoctorId = doctorId, UserTypeEnum = UserTypeEnum.IndependentReviewer, UserTypeId = userType.Id }); + } + + sysUserInfo.Status = UserStateEnum.Enable; + } + + //保证能有userRoleId + await _userRoleRepository.SaveChangesAsync(); }