diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 900180cab..edddbe06c 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -778,11 +778,6 @@ namespace IRaCIS.Core.Application.Contracts var trialType = _repository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault(); - - - - - if (sysUserInfo == null) { @@ -819,25 +814,6 @@ namespace IRaCIS.Core.Application.Contracts } - if (trialType == TrialType.OfficialTrial || trialType == TrialType.Training) - { - - if (sysUserInfo.IsTestUser) - { - throw new BusinessValidationFailedException("正式类型 、培训类型的项目 不允许加入测试用户 "); - - } - } - - if (trialType == TrialType.NoneOfficial) - { - - if (sysUserInfo.IsTestUser == false ) - { - throw new BusinessValidationFailedException("测试项目 不允许加入正式用户 "); - - } - } //发送邮件的时候需要用到该字段 item.SystemUserId = sysUserInfo.Id; diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs index 013c157b3..aad23f9b1 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Core.Application.Contracts { @@ -38,7 +39,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpPost("{trialId:guid}")] public async Task AddOrUpdateTrialSiteUserSurvey(TrialSiteUserSurveyAddOrEdit addOrEditTrialSiteUserSurvey) { - + if (await _trialSiteUserSurveyRepository.Where(t => t.Id == addOrEditTrialSiteUserSurvey.Id).AnyAsync(t => t.TrialSiteSurvey.State == TrialSiteSurveyEnum.PMCreatedAndLock)) { return ResponseOutput.NotOk("已锁定,不允许操作"); @@ -61,6 +62,44 @@ namespace IRaCIS.Core.Application.Contracts } + + if (addOrEditTrialSiteUserSurvey.IsGenerateAccount ) + { + var trialId= _trialSiteUserSurveyRepository.Where(t=>t.Id == addOrEditTrialSiteUserSurvey.TrialSiteSurveyId).Select(t=>t.TrialSiteSurvey.TrialId).FirstOrDefault(); + + var trialType = _repository.Where(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault(); + + var item = addOrEditTrialSiteUserSurvey; + + //找下系统中是否存在该用户类型的 并且邮箱 或者手机的账户 + var sysUserInfo = await _repository.Where(t => t.UserTypeId == item.UserTypeId && t.EMail == item.Email).Include(t => t.UserTypeRole).FirstOrDefaultAsync(); + + if (sysUserInfo == null) + { + sysUserInfo = new User() { IsZhiZhun=false,IsTestUser= (trialType == TrialType.NoneOfficial) }; + } + + if (trialType == TrialType.OfficialTrial || trialType == TrialType.Training) + { + + if (sysUserInfo.IsTestUser) + { + throw new BusinessValidationFailedException("正式类型 、培训类型的项目 不允许加入测试用户 "); + + } + } + + if (trialType == TrialType.NoneOfficial) + { + + if (sysUserInfo.IsTestUser == false) + { + throw new BusinessValidationFailedException("测试项目 不允许加入正式用户 "); + + } + } + } + var entity = await _trialSiteUserSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteUserSurvey, true); return ResponseOutput.Ok(entity.Id.ToString());