From 00cb2fc67c629e545261458bf5bfe8666c6e8931 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 18 Aug 2023 08:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B0=83=E7=A0=94=E8=A1=A8?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SiteSurvey/TrialSiteEquipmentSurveyService.cs | 15 +++++++-------- .../Service/SiteSurvey/TrialSiteSurveyService.cs | 2 +- .../SiteSurvey/TrialSiteUserSurveyService.cs | 5 +++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs index 5a1de2dff..16486d477 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs @@ -17,10 +17,12 @@ namespace IRaCIS.Core.Application.Contracts public class TrialSiteEquipmentSurveyService : BaseService, ITrialSiteEquipmentSurveyService { private readonly IRepository _trialSiteEquipmentSurveyRepository; + private readonly IRepository _trialSiteSurveyRepository; - public TrialSiteEquipmentSurveyService(IRepository trialSiteEquipmentSurveyRepository) + public TrialSiteEquipmentSurveyService(IRepository trialSiteEquipmentSurveyRepository, IRepository trialSiteSurveyRepository) { _trialSiteEquipmentSurveyRepository = trialSiteEquipmentSurveyRepository; + _trialSiteSurveyRepository = trialSiteSurveyRepository; } @@ -38,17 +40,14 @@ namespace IRaCIS.Core.Application.Contracts [HttpPost("{trialId:guid}")] public async Task AddOrUpdateTrialSiteEquipmentSurvey(TrialSiteEquipmentSurveyAddOrEdit addOrEditTrialSiteEquipmentSurvey) { - - if (addOrEditTrialSiteEquipmentSurvey.Id != null) + + if (await _trialSiteSurveyRepository.AnyAsync(t => t.Id == addOrEditTrialSiteEquipmentSurvey.TrialSiteSurveyId && (t.IsDeleted == true ||t.State==TrialSiteSurveyEnum.PMCreatedAndLock), true)) { - if (await _trialSiteEquipmentSurveyRepository.Where(t => t.Id == addOrEditTrialSiteEquipmentSurvey.Id).AnyAsync(t => t.TrialSiteSurvey.State==TrialSiteSurveyEnum.PMCreatedAndLock)) - { - //---已锁定,不允许操作 - return ResponseOutput.NotOk(_localizer["TrialSiteEquipment_Locked"]); - } + return ResponseOutput.NotOk("当前调研表已废除,或者调研表状态已锁定,不允许操作"); } + var entity = await _trialSiteEquipmentSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteEquipmentSurvey, true); return ResponseOutput.Ok(entity.Id.ToString()); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index a42337612..6c6df23da 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -703,7 +703,7 @@ namespace IRaCIS.Core.Application.Contracts if (trialSiteSurvey.IsDeleted == true || trialSiteSurvey.State==TrialSiteSurveyEnum.PMCreatedAndLock) { - throw new BusinessValidationFailedException("当前调研表已废除,或者调研表状态已锁定,不允许提交"); + throw new BusinessValidationFailedException("当前调研表已废除,或者调研表状态已锁定,不允许操作"); } var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.TrialId == trialId && t.TrialSiteSurvey.SiteId == trialSiteSurvey.SiteId && t.TrialSiteSurvey.IsDeleted == false).Select(t => diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs index 131ba5efa..ead243037 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs @@ -48,6 +48,11 @@ namespace IRaCIS.Core.Application.Contracts //---已锁定,不允许操作 return ResponseOutput.NotOk(_localizer["TrialSiteUser_Locked"]); } + + if(await _trialSiteSurveyRepository.AnyAsync(t=>t.Id==addOrEditTrialSiteUserSurvey.TrialSiteSurveyId && t.IsDeleted == true, true)) + { + return ResponseOutput.NotOk("当前调研表已废除,不允许操作"); + } if (addOrEditTrialSiteUserSurvey.IsGenerateAccount )