67 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C#
		
	
	
| //--------------------------------------------------------------------
 | |
| //     此代码由T4模板自动生成  byzhouhang 20210918
 | |
| //	   生成时间 2021-12-23 13:20:59 
 | |
| //     对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
 | |
| //--------------------------------------------------------------------
 | |
| 
 | |
| using IRaCIS.Core.Application.Filter;
 | |
| using IRaCIS.Core.Domain.Share;
 | |
| using Microsoft.AspNetCore.Mvc;
 | |
| 
 | |
| namespace IRaCIS.Core.Application.Contracts
 | |
| {
 | |
|     /// <summary>
 | |
|     /// TrialSiteEquipmentSurveyService
 | |
|     /// </summary>	
 | |
|     [ApiExplorerSettings(GroupName = "Trial")]
 | |
|     public class TrialSiteEquipmentSurveyService(IRepository<TrialSiteEquipmentSurvey> _trialSiteEquipmentSurveyRepository,
 | |
|     IRepository<TrialSiteSurvey> _trialSiteSurveyRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialSiteEquipmentSurveyService
 | |
|     {
 | |
| 
 | |
| 
 | |
| 
 | |
|         [HttpGet("{trialSiteSurveyId:guid}")]
 | |
|         public async Task<List<TrialSiteEquipmentSurveyView>> GetTrialSiteEquipmentSurveyList(Guid trialSiteSurveyId, string? scannerType)
 | |
|         {
 | |
|             var trialSiteEquipmentSurveyQueryable = _trialSiteEquipmentSurveyRepository.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId)
 | |
|             .WhereIf(!string.IsNullOrEmpty(scannerType), t => t.ScannerType.Contains(scannerType!))
 | |
|             .ProjectTo<TrialSiteEquipmentSurveyView>(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us });
 | |
| 
 | |
|             return await trialSiteEquipmentSurveyQueryable.ToListAsync();
 | |
|         }
 | |
| 
 | |
|         [TrialGlobalLimit( "AfterStopCannNotOpt" )]
 | |
|         [HttpPost("{trialId:guid}")]
 | |
|         public async Task<IResponseOutput> AddOrUpdateTrialSiteEquipmentSurvey(TrialSiteEquipmentSurveyAddOrEdit addOrEditTrialSiteEquipmentSurvey)
 | |
|         {
 | |
| 
 | |
|             if (await _trialSiteSurveyRepository.AnyAsync(t => t.Id == addOrEditTrialSiteEquipmentSurvey.TrialSiteSurveyId && (t.IsDeleted == true || t.State == TrialSiteSurveyEnum.PMCreatedAndLock), true))
 | |
|             {
 | |
|                 return ResponseOutput.NotOk(_localizer["TrialSiteEquipment_Invalid"]);
 | |
|             }
 | |
| 
 | |
|             var entity = await _trialSiteEquipmentSurveyRepository.InsertOrUpdateAsync(addOrEditTrialSiteEquipmentSurvey, true);
 | |
| 
 | |
|             return ResponseOutput.Ok(entity.Id.ToString());
 | |
| 
 | |
|         }
 | |
| 
 | |
|         [TrialGlobalLimit( "AfterStopCannNotOpt" )]
 | |
|         [HttpDelete("{trialSiteEquipmentSurveyId:guid}/{trialId:guid}")]
 | |
|         public async Task<IResponseOutput> DeleteTrialSiteEquipmentSurvey(Guid trialSiteEquipmentSurveyId)
 | |
|         {
 | |
|             if (await _trialSiteEquipmentSurveyRepository.Where(t => t.Id == trialSiteEquipmentSurveyId).AnyAsync(t => t.TrialSiteSurvey.State == TrialSiteSurveyEnum.PMCreatedAndLock))
 | |
|             {
 | |
|                 //---已锁定,不允许操作
 | |
|                 return ResponseOutput.NotOk(_localizer["TrialSiteEquipment_Locked"]);
 | |
|             }
 | |
|             await _trialSiteEquipmentSurveyRepository.DeleteFromQueryAsync(t => t.Id == trialSiteEquipmentSurveyId);
 | |
|             var success = await _trialSiteEquipmentSurveyRepository.SaveChangesAsync();
 | |
| 
 | |
|             return ResponseOutput.Result(success);
 | |
|         }
 | |
| 
 | |
| 
 | |
|     }
 | |
| }
 |