diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 1f7782792..bc06ea2b6 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -744,7 +744,7 @@ namespace IRaCIS.Core.Application.Contracts await _trialSiteSurveyRepository.BatchUpdateNoTrackingAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); } - + await _trialSiteSurveyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -1012,67 +1012,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.Ok(); } - /// - /// 提交 后台自动识别是谁提交 - /// - /// - /// - //[TypeFilter(typeof(TrialResourceFilter))] - [HttpPost] - public async Task TrialSurveySubmit(TrialSiteSurvyeSubmitDTO siteSurvyeSubmit) - { - - var trialId = siteSurvyeSubmit.TrialId; - var trialSiteSurveyId = siteSurvyeSubmit.TrialSiteSurveyId; - - if (_userInfo.IsAdmin) - { - return ResponseOutput.NotOk("不允许Admin操作"); - } - - - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined) - { - var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialId && t.Trial.TrialUserList.Any(u => u.User.UserTypeEnum == UserTypeEnum.SPM || u.User.UserTypeEnum == UserTypeEnum.CPM)); - - if (hasSPMOrCPM) - { - await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); - - } - else - { - await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); - - } - - } - else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) - { - - await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id, PreliminaryTime = DateTime.Now }); - - } - else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) - { - - var trialSiteSurvey = _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId).FirstOrDefault(); - - if (trialSiteSurvey == null) return Null404NotFound(trialSiteSurvey); - - - //已生成的不管 管的只需要是 生成失败的并且需要生成账号的 - var needGenerateList = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId && t.IsGenerateAccount && t.IsGenerateSuccess == false).ProjectTo(_mapper.ConfigurationProvider).ToList(); - - - await SendInviteEmail(new InviteEmailCommand() { TrialId = trialId, RouteUrl = siteSurvyeSubmit.RouteUrl, UserList = needGenerateList }); - - await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); - - } - await _trialSiteSurveyRepository.SaveChangesAsync(); - return ResponseOutput.Ok(); - } + } }