diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 2b1eb8c73..a97206d5c 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -118,7 +118,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This item is referenced by content of the trial infomation."); } - var success = await _dicRepository.DeleteFromQueryAsync(t => t.Id == id); + var success = await _dicRepository.BatchDeleteAsync(t => t.Id == id); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs index 2af2b1586..3ed94e835 100644 --- a/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/EmailNoticeConfigService.cs @@ -50,7 +50,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{emailNoticeConfigId:guid}")] public async Task DeleteEmailNoticeConfig(Guid emailNoticeConfigId) { - var success = await repository.DeleteFromQueryAsync(t => t.Id == emailNoticeConfigId); + var success = await repository.BatchDeleteAsync(t => t.Id == emailNoticeConfigId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index 7d1ef6616..ab2e2bd9a 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -214,7 +214,7 @@ namespace IRaCIS.Core.Application.Service { foreach (var item in sortDto.SortData) { - await _frontAuditConfigRepository.UpdateFromQueryAsync(x => x.Id == item.Id, x => new FrontAuditConfig + await _frontAuditConfigRepository.BatchUpdateAsync(x => x.Id == item.Id, x => new FrontAuditConfig { Sort = item.Sort }); @@ -270,7 +270,7 @@ namespace IRaCIS.Core.Application.Service { return ResponseOutput.NotOk("存在子类 无法删除"); } - var success = await _repository.DeleteFromQueryAsync(t => t.Id == frontAuditConfigId); + var success = await _repository.BatchDeleteAsync(t => t.Id == frontAuditConfigId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs b/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs index bf4042238..c41f8de2b 100644 --- a/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs +++ b/IRaCIS.Core.Application/Service/Common/SystemBasicDataService.cs @@ -69,7 +69,7 @@ namespace IRaCIS.Core.Application.Services [HttpDelete("{systemBasicDataId:guid}")] public async Task DeleteSystemBasicData(Guid systemBasicDataId) { - var success = await _repository.DeleteFromQueryAsync(t => t.Id == systemBasicDataId); + var success = await _repository.BatchDeleteAsync(t => t.Id == systemBasicDataId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs index 8f01d41fd..6ec8aca4b 100644 --- a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs @@ -42,7 +42,7 @@ namespace IRaCIS.Application.Services // File.Delete(temp); //} - var success =await _attachmentrepository.DeleteFromQueryAsync(a => a.Id == param.Id); + var success =await _attachmentrepository.BatchDeleteAsync(a => a.Id == param.Id); return ResponseOutput.Result(success); } @@ -139,7 +139,7 @@ namespace IRaCIS.Application.Services //重传的时候,发现 相同语言的官方简历数量为2 那么将重传的简历设置为非官方 if (attachments.Count(t => t.Language == reUpload.Language && t.IsOfficial) == 2) { - await _attachmentrepository.UpdateFromQueryAsync(t => t.Id == reUpload.Id, u => new Attachment() + await _attachmentrepository.BatchUpdateAsync(t => t.Id == reUpload.Id, u => new Attachment() { Path = reUpload.Path, CreateTime = DateTime.Now, @@ -150,7 +150,7 @@ namespace IRaCIS.Application.Services } else //相同语言的重传 { - await _attachmentrepository.UpdateFromQueryAsync(t => t.Id == reUpload.Id, u => new Attachment() + await _attachmentrepository.BatchUpdateAsync(t => t.Id == reUpload.Id, u => new Attachment() { Path = reUpload.Path, CreateTime = DateTime.Now, @@ -241,7 +241,7 @@ namespace IRaCIS.Application.Services [HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")] public async Task SetLanguage(Guid doctorId, Guid attachmentId, int language) { - bool result =await _attachmentrepository.UpdateFromQueryAsync(t => t.Id == attachmentId, a => new Attachment + bool result =await _attachmentrepository.BatchUpdateAsync(t => t.Id == attachmentId, a => new Attachment { Language = language, IsOfficial = false diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs index 4a6b25c4f..4409a47be 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs @@ -113,7 +113,7 @@ namespace IRaCIS.Application.Services var doctor = await _doctorRepository.FirstOrDefaultAsync(t => t.Id == updateModel.Id).IfNullThrowException(); //删除中间表 Title对应的记录 - await _repository.DeleteFromQueryAsync(t => t.DoctorId == updateModel.Id && t.KeyName == StaticData.Title); + await _repository.BatchDeleteAsync(t => t.DoctorId == updateModel.Id && t.KeyName == StaticData.Title); var adddata=new List(); @@ -383,7 +383,7 @@ namespace IRaCIS.Application.Services //_doctorDictionaryRepository.Delete(t => // t.DoctorId == specialtyUpdateModel.Id && t.KeyName == StaticData.ReadingType); - await _repository.DeleteFromQueryAsync(t => + await _repository.BatchDeleteAsync(t => t.DoctorId == specialtyUpdateModel.Id && (t.KeyName == StaticData.Subspeciality || t.KeyName == StaticData.ReadingType)); @@ -431,7 +431,7 @@ namespace IRaCIS.Application.Services { return ResponseOutput.NotOk("Resume & Consultant Agreement must be upload "); } - var success = await _doctorRepository.UpdateFromQueryAsync(o => o.Id == auditResumeParam.Id, u => new Doctor() + var success = await _doctorRepository.BatchUpdateAsync(o => o.Id == auditResumeParam.Id, u => new Doctor() { CooperateStatus = auditResumeParam.CooperateStatus, ResumeStatus = auditResumeParam.ResumeStatus, diff --git a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs index e30859fbe..6f0e63e6f 100644 --- a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs @@ -92,7 +92,7 @@ namespace IRaCIS.Application.Services [HttpDelete, Route("{doctorId:guid}")] public async Task DeleteEducationInfo(Guid id) { - var success = await _educationRepository.DeleteFromQueryAsync(o => o.Id == id); + var success = await _educationRepository.BatchDeleteAsync(o => o.Id == id); return ResponseOutput.Result(success); } @@ -133,7 +133,7 @@ namespace IRaCIS.Application.Services [HttpDelete("{doctorId:guid}")] public async Task DeletePostgraduateInfo(Guid doctorId) { - var success = await _repository.DeleteFromQueryAsync(o => o.Id == doctorId); + var success = await _repository.BatchDeleteAsync(o => o.Id == doctorId); return ResponseOutput.Result(success); } } diff --git a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs b/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs index 704acfb14..4a71aa2a8 100644 --- a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs @@ -112,7 +112,7 @@ namespace IRaCIS.Application.Services _mapper.Map(trialExperienceViewModel, needUpdate); await _repository.UpdateAsync(needUpdate); - await _repository.DeleteFromQueryAsync(t => t.TrialExperienceId == needUpdate.Id); + await _repository.BatchDeleteAsync(t => t.TrialExperienceId == needUpdate.Id); List criteriaList = new List(); @@ -138,7 +138,7 @@ namespace IRaCIS.Application.Services [HttpDelete, Route("{doctorId:guid}")] public async Task DeleteTrialExperience(Guid doctorId) { - var success = await _repository.DeleteFromQueryAsync(o => o.Id == doctorId); + var success = await _repository.BatchDeleteAsync(o => o.Id == doctorId); return ResponseOutput.Result(success); } /// @@ -152,7 +152,7 @@ namespace IRaCIS.Application.Services { //_attachmentRepository.Delete(t => t.DoctorId == updateGCPExperienceParam.Id && t.Type == StaticData.GCP); - var successs = await _repository.UpdateFromQueryAsync(o => o.Id == updateGCPExperienceParam.Id, u => new Doctor() + var successs = await _repository.BatchUpdateAsync(o => o.Id == updateGCPExperienceParam.Id, u => new Doctor() { GCP = updateGCPExperienceParam.GCP, GCPId = updateGCPExperienceParam.GCP==0&&updateGCPExperienceParam.GCPId==null?Guid.Empty: updateGCPExperienceParam.GCPId!.Value @@ -160,7 +160,7 @@ namespace IRaCIS.Application.Services if (updateGCPExperienceParam.GCP == 0 && updateGCPExperienceParam.GCPId != null) { - await _repository.DeleteFromQueryAsync(a => a.Id == updateGCPExperienceParam.GCPId); + await _repository.BatchDeleteAsync(a => a.Id == updateGCPExperienceParam.GCPId); } @@ -176,7 +176,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task UpdateOtherExperience(ClinicalExperienceCommand updateOtherClinicalExperience) { - var success = await _repository.UpdateFromQueryAsync(o => o.Id == updateOtherClinicalExperience.DoctorId, u => new Doctor() + var success = await _repository.BatchUpdateAsync(o => o.Id == updateOtherClinicalExperience.DoctorId, u => new Doctor() { OtherClinicalExperience = updateOtherClinicalExperience.OtherClinicalExperience ?? string.Empty, OtherClinicalExperienceCN = updateOtherClinicalExperience.OtherClinicalExperienceCN ?? string.Empty diff --git a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs b/IRaCIS.Core.Application/Service/Doctor/VacationService.cs index 2b46ccff1..4d4fb9d5a 100644 --- a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/VacationService.cs @@ -35,7 +35,7 @@ namespace IRaCIS.Application.Services } else { - var success = await _vacationRepository.UpdateFromQueryAsync(u => u.Id == param.Id, + var success = await _vacationRepository.BatchUpdateAsync(u => u.Id == param.Id, h => new Vacation { StartDate = param.StartDate, @@ -56,7 +56,7 @@ namespace IRaCIS.Application.Services [HttpDelete("{holidayId:guid}")] public async Task DeleteVacation(Guid holidayId) { - var success = await _vacationRepository.DeleteFromQueryAsync(u => u.Id == holidayId); + var success = await _vacationRepository.BatchDeleteAsync(u => u.Id == holidayId); return ResponseOutput.Result(success); diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs index 78ab982e7..15bc7caf3 100644 --- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs @@ -113,7 +113,7 @@ namespace IRaCIS.Core.Application.Services return ResponseOutput.NotOk("该文档下已有签名的用户"); } - var success = await _repository.DeleteFromQueryAsync(t => t.Id == systemDocumentId); + var success = await _repository.BatchDeleteAsync(t => t.Id == systemDocumentId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index ad567c20a..bb956a6fc 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -464,7 +464,7 @@ namespace IRaCIS.Core.Application.Services return ResponseOutput.NotOk("该文档,已有用户签名 不允许删除"); } - var success = await _trialDocumentRepository.DeleteFromQueryAsync(t => t.Id == trialDocumentId); + var success = await _trialDocumentRepository.BatchDeleteAsync(t => t.Id == trialDocumentId); return ResponseOutput.Result(success); } @@ -580,11 +580,11 @@ namespace IRaCIS.Core.Application.Services { if (isSystemDoc) { - await _repository.UpdateFromQueryAsync(t => t.Id == documentId, u => new SystemDocument() { IsDeleted = true }); + await _repository.BatchUpdateAsync(t => t.Id == documentId, u => new SystemDocument() { IsDeleted = true }); } else { - await _trialDocumentRepository.UpdateFromQueryAsync(t => t.Id == documentId, u => new TrialDocument() { IsDeleted = true }); + await _trialDocumentRepository.BatchUpdateAsync(t => t.Id == documentId, u => new TrialDocument() { IsDeleted = true }); } return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs b/IRaCIS.Core.Application/Service/Financial/CalculateService.cs index fb40d46e3..6432f953d 100644 --- a/IRaCIS.Core.Application/Service/Financial/CalculateService.cs +++ b/IRaCIS.Core.Application/Service/Financial/CalculateService.cs @@ -595,7 +595,7 @@ namespace IRaCIS.Application.Services foreach (var reviewer in needUpdatePayment) { - await _paymentRepository.UpdateFromQueryAsync(u => u.YearMonth == yearMonth && + await _paymentRepository.BatchUpdateAsync(u => u.YearMonth == yearMonth && !u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment() { AdjustmentUSD = reviewer.AdjustUSD, @@ -638,12 +638,12 @@ namespace IRaCIS.Application.Services // 如果是 当月计算的工作量费用 和 调整费用都为0,则删除该行记录 if (addOrUpdateModel.PaymentUSD == 0 && paymentModel.AdjustmentUSD == 0) { - success =await _paymentRepository.DeleteFromQueryAsync(u => u.Id == paymentModel.Id); + success =await _paymentRepository.BatchDeleteAsync(u => u.Id == paymentModel.Id); //_paymentDetailRepository.Delete(u=>u.PaymentId==paymentModel.Id); } else { - success = await _paymentRepository.UpdateFromQueryAsync(t => t.Id == paymentModel.Id, u => new Payment() + success = await _paymentRepository.BatchUpdateAsync(t => t.Id == paymentModel.Id, u => new Payment() { PaymentUSD = addOrUpdateModel.PaymentUSD, CalculateTime = addOrUpdateModel.CalculateTime, @@ -670,7 +670,7 @@ namespace IRaCIS.Application.Services private async Task AddOrUpdateMonthlyPaymentDetail(List addOrUpdateList, Guid paymentId) { //var paymentDetailIds = addOrUpdateList.Select(t => t.PaymentId).ToList(); - await _paymentDetailRepository.DeleteFromQueryAsync(t => t.PaymentId == paymentId); + await _paymentDetailRepository.BatchDeleteAsync(t => t.PaymentId == paymentId); await _paymentDetailRepository.AddRangeAsync(_mapper.Map>(addOrUpdateList)); return await _paymentDetailRepository.SaveChangesAsync(); } diff --git a/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs b/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs index 5e81ce968..17b04fe3a 100644 --- a/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs +++ b/IRaCIS.Core.Application/Service/Financial/ExchangeRateService.cs @@ -46,7 +46,7 @@ namespace IRaCIS.Application.Services } else { - var success = await _exchangeRateRepository.UpdateFromQueryAsync(t => t.Id == model.Id, u => new ExchangeRate() + var success = await _exchangeRateRepository.BatchUpdateAsync(t => t.Id == model.Id, u => new ExchangeRate() { //YearMonth = model.YearMonth, Rate = model.Rate, @@ -72,7 +72,7 @@ namespace IRaCIS.Application.Services } - var success = await _exchangeRateRepository.DeleteFromQueryAsync(t => t.Id == id); + var success = await _exchangeRateRepository.BatchDeleteAsync(t => t.Id == id); return ResponseOutput.Ok(success); } diff --git a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs b/IRaCIS.Core.Application/Service/Financial/FinancialService.cs index b531e5317..191a6314c 100644 --- a/IRaCIS.Core.Application/Service/Financial/FinancialService.cs +++ b/IRaCIS.Core.Application/Service/Financial/FinancialService.cs @@ -1256,18 +1256,18 @@ namespace IRaCIS.Application.Services var isLock = param.IsLock; - var paymentLockSuccess = await _paymentRepository.UpdateFromQueryAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, t => new Payment + var paymentLockSuccess = await _paymentRepository.BatchUpdateAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, t => new Payment { IsLock = isLock }); - var adjustmentLockSuccess = await _payAdjustmentRepository.UpdateFromQueryAsync( + var adjustmentLockSuccess = await _payAdjustmentRepository.BatchUpdateAsync( t => t.YearMonth == yearMonth && reviewerIds.Contains(t.ReviewerId), u => new PaymentAdjustment() { IsLock = true }); - await _doctorWorkloadRepository.UpdateFromQueryAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, + await _doctorWorkloadRepository.BatchUpdateAsync(u => reviewerIds.Contains(u.DoctorId) && u.YearMonth == yearMonth, t => new Workload { IsLock = true }); return ResponseOutput.Result(paymentLockSuccess || adjustmentLockSuccess); diff --git a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs b/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs index 6e312d043..5a2642d50 100644 --- a/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs +++ b/IRaCIS.Core.Application/Service/Financial/PaymentAdjustmentService.cs @@ -255,7 +255,7 @@ namespace IRaCIS.Application.Services { //如果是double 不会保留两位小数 - await _payAdjustmentRepository.UpdateFromQueryAsync(u => u.YearMonth == yearMonth && + await _payAdjustmentRepository.BatchUpdateAsync(u => u.YearMonth == yearMonth && !u.IsLock, t => new PaymentAdjustment { AdjustmentCNY = t.AdjustmentUSD * rate, @@ -277,7 +277,7 @@ namespace IRaCIS.Application.Services foreach (var reviewer in needUpdatePayment) { - await _paymentRepository.UpdateFromQueryAsync(u => u.YearMonth == yearMonth && + await _paymentRepository.BatchUpdateAsync(u => u.YearMonth == yearMonth && !u.IsLock && u.DoctorId == reviewer.ReviewerId, t => new Payment() { AdjustmentUSD = reviewer.AdjustUSD, diff --git a/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs b/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs index 29179102f..9768ec39c 100644 --- a/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs +++ b/IRaCIS.Core.Application/Service/Financial/RankPriceService.cs @@ -43,7 +43,7 @@ namespace IRaCIS.Application.Services } else { - var success =await _rankPriceRepository.UpdateFromQueryAsync(t => t.Id == addOrUpdateModel.Id, u => new RankPrice() + var success =await _rankPriceRepository.BatchUpdateAsync(t => t.Id == addOrUpdateModel.Id, u => new RankPrice() { UpdateUserId = userId, UpdateTime = DateTime.Now, @@ -76,7 +76,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This title has been used by reviewer payment information"); } - var success = await _rankPriceRepository.DeleteFromQueryAsync(t => t.Id == id); + var success = await _rankPriceRepository.BatchDeleteAsync(t => t.Id == id); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs index 9cae75653..32262dd57 100644 --- a/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs +++ b/IRaCIS.Core.Application/Service/Financial/TrialPaymentPriceService.cs @@ -78,7 +78,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task DeleteTrialSOW(DeleteSowPathDTO trialSowPath) { - var success = await _trialExtRepository.UpdateFromQueryAsync(u => u.TrialId == trialSowPath.TrialId, s => new TrialPaymentPrice + var success = await _trialExtRepository.BatchUpdateAsync(u => u.TrialId == trialSowPath.TrialId, s => new TrialPaymentPrice { SowPath = "", SowName = "", diff --git a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs index 672bf755d..5b7b6074b 100644 --- a/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs +++ b/IRaCIS.Core.Application/Service/Financial/TrialRevenuesPriceService.cs @@ -63,7 +63,7 @@ namespace IRaCIS.Application.Services // 完善价格的 将对应的列设置为true 变更为有价格了 - var aaa = await _trialRevenuesPriceVerificationRepository.UpdateFromQueryAsync(t => t.TrialId == model.TrialId, u => new TrialRevenuesPriceVerification() + var aaa = await _trialRevenuesPriceVerificationRepository.BatchUpdateAsync(t => t.TrialId == model.TrialId, u => new TrialRevenuesPriceVerification() { //有价格 则设置为true 否则 该列不变 Timepoint = model.Timepoint > 0 || u.Timepoint, @@ -81,7 +81,7 @@ namespace IRaCIS.Application.Services }); //删除所有有价格的记录 为true 表示有价格或者不需要价格 缺价格的为false - await _trialRevenuesPriceVerificationRepository.DeleteFromQueryAsync(t => t.TrialId == model.TrialId && + await _trialRevenuesPriceVerificationRepository.BatchDeleteAsync(t => t.TrialId == model.TrialId && t.Timepoint&& t.TimepointIn24H&& t.TimepointIn48H && @@ -101,7 +101,7 @@ namespace IRaCIS.Application.Services [NonDynamicMethod] public async Task DeleteTrialCost(Guid id) { - return await _trialRevenuesPriceRepository.DeleteFromQueryAsync(u => u.Id == id); + return await _trialRevenuesPriceRepository.BatchDeleteAsync(u => u.Id == id); } /// diff --git a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs b/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs index e72f3d43f..742d8da2c 100644 --- a/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs +++ b/IRaCIS.Core.Application/Service/Financial/VolumeRewardService.cs @@ -28,7 +28,7 @@ namespace IRaCIS.Application.Services [NonDynamicMethod] public async Task AddOrUpdateVolumeRewardPriceList(IEnumerable addOrUpdateModel) { - await _volumeRewardRepository.DeleteFromQueryAsync(t => t.Id != Guid.Empty); + await _volumeRewardRepository.BatchDeleteAsync(t => t.Id != Guid.Empty); var temp = _mapper.Map>(addOrUpdateModel); await _volumeRewardRepository.AddRangeAsync(temp); diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs index d25f2fe36..3492b9f22 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs @@ -57,7 +57,7 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{systemAnonymizationId:guid}")] public async Task DeleteSystemAnonymization(Guid systemAnonymizationId) { - var success = await systemAnonymizationRepository.DeleteFromQueryAsync(t => t.Id == systemAnonymizationId); + var success = await systemAnonymizationRepository.BatchDeleteAsync(t => t.Id == systemAnonymizationId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 1e0707772..04c18a707 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -212,7 +212,7 @@ namespace IRaCIS.Core.Application.Service.Inspection if (AuditInfo.IsSign) { - var signSuccess = await _repository.UpdateFromQueryAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); + var signSuccess = await _repository.BatchUpdateAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); } // 判断是否需要前面 diff --git a/IRaCIS.Core.Application/Service/Institution/CROService.cs b/IRaCIS.Core.Application/Service/Institution/CROService.cs index 6a0308efa..9fea6a0bb 100644 --- a/IRaCIS.Core.Application/Service/Institution/CROService.cs +++ b/IRaCIS.Core.Application/Service/Institution/CROService.cs @@ -70,7 +70,7 @@ namespace IRaCIS.Application.Services //{ // return ResponseOutput.NotOk("该CRO下存在用户,暂时无法删除。"); //} - var success = await _croRepository.DeleteFromQueryAsync(x=>x.Id== cROCompanyId); + var success = await _croRepository.BatchDeleteAsync(x=>x.Id== cROCompanyId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs index 2fead7eeb..4884b0638 100644 --- a/IRaCIS.Core.Application/Service/Institution/HospitalService.cs +++ b/IRaCIS.Core.Application/Service/Institution/HospitalService.cs @@ -54,7 +54,7 @@ namespace IRaCIS.Application.Services // return ResponseOutput.NotOk("该医院下存在用户,暂时无法删除。"); //} - var success = await _hospitalRepository.DeleteFromQueryAsync(x => x.Id == hospitalId); + var success = await _hospitalRepository.BatchDeleteAsync(x => x.Id == hospitalId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index 1a86b1795..c4113ed98 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -69,7 +69,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This site has participated in the trial and couldn't be deleted."); } - var success = await _siteRepository.DeleteFromQueryAsync(x => x.Id == siteId); + var success = await _siteRepository.BatchDeleteAsync(x => x.Id == siteId); return ResponseOutput.Result(success); } } diff --git a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs index 5d27e2ed5..215755a03 100644 --- a/IRaCIS.Core.Application/Service/Institution/SponsorService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SponsorService.cs @@ -75,7 +75,7 @@ namespace IRaCIS.Application.Services //} - var success = await _sponsorRepository.DeleteFromQueryAsync(x => x.Id == sponsorId); + var success = await _sponsorRepository.BatchDeleteAsync(x => x.Id == sponsorId); return ResponseOutput.Result(success); } } diff --git a/IRaCIS.Core.Application/Service/Management/MenuService.cs b/IRaCIS.Core.Application/Service/Management/MenuService.cs index c78901377..65c2e5130 100644 --- a/IRaCIS.Core.Application/Service/Management/MenuService.cs +++ b/IRaCIS.Core.Application/Service/Management/MenuService.cs @@ -93,7 +93,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("不允许直接删除父节点"); } - var success =await menuRepository.DeleteFromQueryAsync(u => u.Id == menuId); + var success =await menuRepository.BatchDeleteAsync(u => u.Id == menuId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index ea499bd59..85eb5854b 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -108,13 +108,13 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("The mailbox for this user type already exists"); } - var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new User() + var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User() { EMail = newEmail }); //删除验证码历史记录 - await _verificationCodeRepository.DeleteFromQueryAsync(t => t.UserId == _userInfo.Id && t.CodeType == 0); + await _verificationCodeRepository.BatchDeleteAsync(t => t.UserId == _userInfo.Id && t.CodeType == 0); return ResponseOutput.Result(success); @@ -128,7 +128,7 @@ namespace IRaCIS.Application.Services { - var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new User() + var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User() { Phone = newPhone }); @@ -145,7 +145,7 @@ namespace IRaCIS.Application.Services { return ResponseOutput.NotOk("UserId already exists"); } - var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new User() + var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User() { UserName = newUserName }); @@ -163,7 +163,7 @@ namespace IRaCIS.Application.Services public async Task ResetPassword(Guid userId) { - var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == userId, u => new User() + var success = await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User() { Password = MD5Helper.Md5(StaticData.DefaultPassword), IsFirstAdd = true @@ -243,7 +243,7 @@ namespace IRaCIS.Application.Services { //删除验证码历史记录 - await _verificationCodeRepository.DeleteFromQueryAsync(t => t.Id == verificationRecord.Id); + await _verificationCodeRepository.BatchDeleteAsync(t => t.Id == verificationRecord.Id); } } @@ -275,7 +275,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("password not change"); } - var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == userId, u => new User() + var success = await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User() { Password = newPwd, IsFirstAdd = false @@ -312,14 +312,14 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("UserId already exists"); } - await _userRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new User() + await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User() { UserName = editPwModel.NewUserName, }); } - var success = await _userRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new User() + var success = await _userRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new User() { Password = editPwModel.NewPassWord, IsFirstAdd = false @@ -333,7 +333,7 @@ namespace IRaCIS.Application.Services //医生密码 if (await _doctorRepository.AnyAsync(t => t.Id == _userInfo.Id && t.Password == editPwModel.OldPassWord)) { - var success = await _doctorRepository.UpdateFromQueryAsync(t => t.Id == _userInfo.Id, u => new Doctor() + var success = await _doctorRepository.BatchUpdateAsync(t => t.Id == _userInfo.Id, u => new Doctor() { Password = editPwModel.NewPassWord @@ -460,7 +460,7 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This user has participated in the trial and couldn't be deleted"); } - var success = await _userRepository.DeleteFromQueryAsync(t => t.Id == userId); + var success = await _userRepository.BatchDeleteAsync(t => t.Id == userId); return ResponseOutput.Result(success); } @@ -475,7 +475,7 @@ namespace IRaCIS.Application.Services [HttpPost("{userId:guid}/{state:int}")] public async Task UpdateUserState(Guid userId, UserStateEnum state) { - var success = await _userRepository.UpdateFromQueryAsync(u => u.Id == userId, t => new User + var success = await _userRepository.BatchUpdateAsync(u => u.Id == userId, t => new User { Status = state }); diff --git a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs index de5bd8897..7ad3d0187 100644 --- a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs @@ -83,7 +83,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("该用户类型,被某些用户已使用,不能删除"); } - var success = await userTypeServiceRepository.DeleteFromQueryAsync(t => t.Id == userTypeId); + var success = await userTypeServiceRepository.BatchDeleteAsync(t => t.Id == userTypeId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs b/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs index dcf5c5639..dc0ff0b1d 100644 --- a/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs @@ -166,7 +166,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{trialId:guid}/{previousHistoryId:guid}")] public async Task DeletePreviousHistory(Guid previousHistoryId) { - var success = await _previousHistoryRepository.DeleteFromQueryAsync(t => t.Id == previousHistoryId); + var success = await _previousHistoryRepository.BatchDeleteAsync(t => t.Id == previousHistoryId); return ResponseOutput.Result(success); } @@ -191,7 +191,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{trialId:guid}/{previousOtherId:guid}")] public async Task DeletePreviousOther(Guid previousOtherId) { - var success = await _previousOtherRepository.DeleteFromQueryAsync(t => t.Id == previousOtherId); + var success = await _previousOtherRepository.BatchDeleteAsync(t => t.Id == previousOtherId); return ResponseOutput.Result(success); } @@ -216,7 +216,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{trialId:guid}/{previousSurgeryId:guid}")] public async Task DeletePreviousSurgery(Guid previousSurgeryId) { - var success = await _previousSurgeryRepository.DeleteFromQueryAsync(t => t.Id == previousSurgeryId); + var success = await _previousSurgeryRepository.BatchDeleteAsync(t => t.Id == previousSurgeryId); return ResponseOutput.Result(success); } @@ -242,7 +242,7 @@ namespace IRaCIS.Core.Application.Contracts public async Task DeletePreviousPDF(Guid previousPDFId) { - var success = await _previousPdfRepository.DeleteFromQueryAsync(t => t.Id == previousPDFId); + var success = await _previousPdfRepository.BatchDeleteAsync(t => t.Id == previousPDFId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index fac5e94c6..56bd54c07 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -78,7 +78,7 @@ namespace IRaCIS.Core.Application.Contracts var minArray = new DateTime?[] { svTime.DicomStudyMinStudyTime, svTime.NoneDicomStudyMinStudyTime, addOrEditNoneDicomStudy.ImageDate }; var maxArray = new DateTime?[] { svTime.DicomStudyMaxStudyTime, svTime.NoneDicomStudyMaxStudyTime, addOrEditNoneDicomStudy.ImageDate }; - await _repository.UpdateFromQueryAsync(t => t.Id == addOrEditNoneDicomStudy.SubjectVisitId, u => new SubjectVisit() + await _repository.BatchUpdateAsync(t => t.Id == addOrEditNoneDicomStudy.SubjectVisitId, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Executed, @@ -112,8 +112,8 @@ namespace IRaCIS.Core.Application.Contracts if (noneDicomStudy == null) return Null404NotFound(noneDicomStudy); - await _noneDicomStudyRepository.DeleteFromQueryAsync(t => t.Id == noneDicomStudyId); - await _noneDicomStudyFileRepository.DeleteFromQueryAsync(t => t.NoneDicomStudyId == noneDicomStudyId); + await _noneDicomStudyRepository.BatchDeleteAsync(t => t.Id == noneDicomStudyId); + await _noneDicomStudyFileRepository.BatchDeleteAsync(t => t.NoneDicomStudyId == noneDicomStudyId); var svTime = await _repository.Where(t => t.Id == noneDicomStudy.SubjectVisitId).Select(t => new { @@ -126,7 +126,7 @@ namespace IRaCIS.Core.Application.Contracts var minArray = new DateTime?[] { svTime.DicomStudyMinStudyTime, svTime.NoneDicomStudyMinStudyTime }; var maxArray = new DateTime?[] { svTime.DicomStudyMaxStudyTime, svTime.NoneDicomStudyMaxStudyTime }; - await _repository.UpdateFromQueryAsync(t => t.Id == noneDicomStudy.SubjectVisitId, u => new SubjectVisit() + await _repository.BatchUpdateAsync(t => t.Id == noneDicomStudy.SubjectVisitId, u => new SubjectVisit() { EarliestScanDate = minArray.Min(), @@ -136,7 +136,7 @@ namespace IRaCIS.Core.Application.Contracts //如果既没有 dicom数据 也没有非dicom 文件 那么提交状态变更回去 if (await _repository.CountAsync(t => t.SubjectVisitId == noneDicomStudy.SubjectVisitId) == 0 && await _repository.CountAsync(t => t.NoneDicomStudy.SubjectVisitId == noneDicomStudy.SubjectVisitId) == 0) { - await _repository.UpdateFromQueryAsync(t => t.Id == noneDicomStudy.SubjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SubmitState = SubmitStateEnum.None }); + await _repository.BatchUpdateAsync(t => t.Id == noneDicomStudy.SubjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SubmitState = SubmitStateEnum.None }); } return ResponseOutput.Ok(); } @@ -147,12 +147,12 @@ namespace IRaCIS.Core.Application.Contracts { var subjectVisitId = await _noneDicomStudyFileRepository.Where(t=>t.Id== noneDicomStudyFileId).Select(t => t.NoneDicomStudy.SubjectVisitId).FirstOrDefaultAsync(); - var success = await _noneDicomStudyFileRepository.DeleteFromQueryAsync(t => t.Id == noneDicomStudyFileId); + var success = await _noneDicomStudyFileRepository.BatchDeleteAsync(t => t.Id == noneDicomStudyFileId); //如果既没有 dicom数据 也没有非dicom 文件 那么提交状态变更回去 if (await _repository.CountAsync(t => t.SubjectVisitId == subjectVisitId) == 0 && await _repository.CountAsync(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId) == 0) { - await _repository.UpdateFromQueryAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SubmitState = SubmitStateEnum.None }); + await _repository.BatchUpdateAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SubmitState = SubmitStateEnum.None }); } @@ -296,7 +296,7 @@ namespace IRaCIS.Core.Application.Contracts } // 上传非Dicom 后 将状态改为待提交 分为普通上传 和QC后重传 普通上传时才改为待提交 - await _repository.UpdateFromQueryAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.None, u => new SubjectVisit() { SubmitState = SubmitStateEnum.ToSubmit }); + await _repository.BatchUpdateAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.None, u => new SubjectVisit() { SubmitState = SubmitStateEnum.ToSubmit }); await _repository.AddAsync(new StudyMonitor() { diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 084e5dd34..89e3f595f 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -464,7 +464,7 @@ namespace IRaCIS.Core.Application.Image.QA { return ResponseOutput.NotOk("核查通过的数据不允许申请回退"); } - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { RequestBackState = RequestBackStateEnum.CRC_RequestBack }); + await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { RequestBackState = RequestBackStateEnum.CRC_RequestBack }); return ResponseOutput.Ok(); @@ -528,7 +528,7 @@ namespace IRaCIS.Core.Application.Image.QA //_checkChallengeDialogRepository.Delete(t => t.SubjectVisitId == subjectVisitId); await _repository.AddAsync(new CheckChallengeDialog() { SubjectVisitId = subjectVisitId, TalkContent = "PM执行了一致性核查回退", UserTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt }); - await _repository.DeleteFromQueryAsync(t => t.SubjectVisitId == subjectVisitId); + await _repository.BatchDeleteAsync(t => t.SubjectVisitId == subjectVisitId); var success = await _repository.SaveChangesAsync(); @@ -908,7 +908,7 @@ namespace IRaCIS.Core.Application.Image.QA study.BodyPartForEdit = bodyPart; study.Modalities = modality; - await _repository.UpdateFromQueryAsync(t => t.StudyId == id, r => new DicomSeries() { BodyPartForEdit = bodyPart, Modality = modality }); + await _repository.BatchUpdateAsync(t => t.StudyId == id, r => new DicomSeries() { BodyPartForEdit = bodyPart, Modality = modality }); } else if (type == 2) @@ -1008,9 +1008,9 @@ namespace IRaCIS.Core.Application.Image.QA foreach (var id in ids) { - var success1 = await _repository.DeleteFromQueryAsync(t => t.Id == id); - var succeess2 = await _repository.DeleteFromQueryAsync(t => t.StudyId == id); - var success3 = await _repository.DeleteFromQueryAsync(t => t.StudyId == id); + var success1 = await _repository.BatchDeleteAsync(t => t.Id == id); + var succeess2 = await _repository.BatchDeleteAsync(t => t.StudyId == id); + var success3 = await _repository.BatchDeleteAsync(t => t.StudyId == id); //删除 物理文件 @@ -1034,7 +1034,7 @@ namespace IRaCIS.Core.Application.Image.QA //一个访视下面有多个检查,所以需要检测 没有的时候才清空 非dicom 是检查文件 不是表记录 if (await _repository.CountAsync(t => t.SubjectVisitId == subjectVisitId) == 0 && await _repository.CountAsync(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId) == 0) { - await _repository.UpdateFromQueryAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, + await _repository.BatchUpdateAsync(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.ToSubmit, u => new SubjectVisit() { VisitExecuted = 0, SVENDTC = null, SVSTDTC = null, SubmitState = SubmitStateEnum.None }); //_qaNoticeRepository.Delete(t => t.SubjectVisitId == subjectVisitId); @@ -1057,7 +1057,7 @@ namespace IRaCIS.Core.Application.Image.QA var minArray = new DateTime?[] { svTime.DicomStudyMinStudyTime, svTime.NoneDicomStudyMinStudyTime }; var maxArray = new DateTime?[] { svTime.DicomStudyMaxStudyTime, svTime.NoneDicomStudyMaxStudyTime }; - await _repository.UpdateFromQueryAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() + await _repository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { EarliestScanDate = minArray.Min(), @@ -1546,7 +1546,7 @@ namespace IRaCIS.Core.Application.Image.QA await _repository.SaveChangesAsync(); - var success = await _repository.UpdateFromQueryAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); + var success = await _repository.BatchUpdateAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); return ResponseOutput.Result(success); @@ -1615,7 +1615,7 @@ namespace IRaCIS.Core.Application.Image.QA qcChallenge.LatestMsgTime = DateTime.Now; qcChallenge.LatestReplyUserId = _userInfo.Id; - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = true }); + await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = true }); qcChallenge.DialogList.Add(new QCChallengeDialog() { @@ -1651,11 +1651,11 @@ namespace IRaCIS.Core.Application.Image.QA //删除1QC 填写的问题答案 - await _repository.DeleteFromQueryAsync(t => t.SubjectVisitId == qcChallenge.SubjectVisitId && t.CurrentQCEnum == CurrentQC.First); + await _repository.BatchDeleteAsync(t => t.SubjectVisitId == qcChallenge.SubjectVisitId && t.CurrentQCEnum == CurrentQC.First); //2QC 数据变为1QC - await _repository.UpdateFromQueryAsync(t => t.SubjectVisitId == qcChallenge.SubjectVisitId && t.CurrentQCEnum == CurrentQC.Second, k => new QCChallenge() { CurrentQCEnum = CurrentQC.First }); - await _repository.UpdateFromQueryAsync(t => t.SubjectVisitId == qcChallenge.SubjectVisitId && t.CurrentQCEnum == CurrentQC.Second, k => new TrialQCQuestionAnswer() { CurrentQCEnum = CurrentQC.First }); + await _repository.BatchUpdateAsync(t => t.SubjectVisitId == qcChallenge.SubjectVisitId && t.CurrentQCEnum == CurrentQC.Second, k => new QCChallenge() { CurrentQCEnum = CurrentQC.First }); + await _repository.BatchUpdateAsync(t => t.SubjectVisitId == qcChallenge.SubjectVisitId && t.CurrentQCEnum == CurrentQC.Second, k => new TrialQCQuestionAnswer() { CurrentQCEnum = CurrentQC.First }); } @@ -1707,7 +1707,7 @@ namespace IRaCIS.Core.Application.Image.QA var dbSubjectVisit = await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == qcChallenge.SubjectVisitId).IfNullThrowException(); - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = false }); + await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == qcChallenge.SubjectVisitId, c => new SubjectVisit() { IsQCConfirmedReupload = false }); qcChallenge.DialogList.Add(new QCChallengeDialog() { @@ -1727,7 +1727,7 @@ namespace IRaCIS.Core.Application.Image.QA //已确认临床数据完整性 dbSubjectVisit.IsConfirmedClinicalData = true; - var signSuccess = await _repository.UpdateFromQueryAsync(t => t.Id == cRCReuploadFinishedCommand.SignId, u => new TrialSign() { IsCompleted = true }); + var signSuccess = await _repository.BatchUpdateAsync(t => t.Id == cRCReuploadFinishedCommand.SignId, u => new TrialSign() { IsCompleted = true }); } @@ -1798,7 +1798,7 @@ namespace IRaCIS.Core.Application.Image.QA return ResponseOutput.NotOk("回退的访视,不允许修改PD确认状态"); } - await _repository.UpdateFromQueryAsync(t => t.Id == command.SubjectVisitId, u => new SubjectVisit() + await _repository.BatchUpdateAsync(t => t.Id == command.SubjectVisitId, u => new SubjectVisit() { IsEnrollmentConfirm = command.IsEnrollmentConfirm.Value, }); @@ -1812,7 +1812,7 @@ namespace IRaCIS.Core.Application.Image.QA { List datas = new List(); var data = await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == command.SubjectVisitId); - await _repository.UpdateFromQueryAsync(t => t.Id == command.SubjectId, u => new Subject() + await _repository.BatchUpdateAsync(t => t.Id == command.SubjectId, u => new Subject() { FirstGiveMedicineTime = command.SubjectFirstGiveMedicineTime, @@ -1928,7 +1928,7 @@ namespace IRaCIS.Core.Application.Image.QA if (!result.IsSuccess) { - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.Id == subjectVisitId, + await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { ForwardState = ForwardStateEnum.ForwardFailed }); return ResponseOutput.NotOk("Forward Failed" + result.Failures.ToString() + result.ToJson()); @@ -1943,11 +1943,11 @@ namespace IRaCIS.Core.Application.Image.QA catch (Exception e) { - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.Id == subjectVisitId, + await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { ForwardState = ForwardStateEnum.ForwardFailed }); } - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.Id == subjectVisitId, + await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { ForwardState = ForwardStateEnum.Forwarded,ForwardUserId = _userInfo.Id,ForwardTime = DateTime.Now}); } diff --git a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs index fe0d94b36..644c07fe8 100644 --- a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs @@ -46,7 +46,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{qCQuestionConfigureId:guid}")] public async Task DeleteQCQuestionConfigure(Guid qCQuestionConfigureId) { - var success = await _qcQuestionRepository.DeleteFromQueryAsync(t => t.Id == qCQuestionConfigureId); + var success = await _qcQuestionRepository.BatchDeleteAsync(t => t.Id == qCQuestionConfigureId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs index 2f4b91753..d21c00223 100644 --- a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs @@ -151,7 +151,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已有QC审核记录,不允许删除问题项"); } - var success = await _trialQcQuestionRepository.DeleteFromQueryAsync(t => t.Id == trialQCQuestionConfigureId); + var success = await _trialQcQuestionRepository.BatchDeleteAsync(t => t.Id == trialQCQuestionConfigureId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs index bad6e77b1..2924197ba 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteEquipmentSurveyService.cs @@ -72,7 +72,7 @@ namespace IRaCIS.Core.Application.Contracts { return ResponseOutput.NotOk("已锁定,不允许操作"); } - var success = await _trialSiteEquipmentSurveyRepository.DeleteFromQueryAsync(t => t.Id == trialSiteEquipmentSurveyId); + var success = await _trialSiteEquipmentSurveyRepository.BatchDeleteAsync(t => t.Id == trialSiteEquipmentSurveyId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index da50c9f09..a08429368 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -273,7 +273,7 @@ namespace IRaCIS.Core.Application.Contracts //删除验证码历史记录 - await _repository.DeleteFromQueryAsync(t => t.EmailOrPhone == userInfo.EmailOrPhone && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); + await _repository.BatchDeleteAsync(t => t.EmailOrPhone == userInfo.EmailOrPhone && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); await _repository.SaveChangesAsync(); @@ -349,7 +349,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已锁定,不允许操作"); } - var success = await _trialSiteSurveyRepository.DeleteFromQueryAsync(t => t.Id == trialSiteSurveyId); + var success = await _trialSiteSurveyRepository.BatchDeleteAsync(t => t.Id == trialSiteSurveyId); return ResponseOutput.Result(success); } @@ -600,7 +600,7 @@ namespace IRaCIS.Core.Application.Contracts if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) { - await _repository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); + await _repository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); } else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) { @@ -608,12 +608,12 @@ namespace IRaCIS.Core.Application.Contracts if (hasSPMOrCPM) { - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); + await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); } else { - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); + await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.ToSubmit }); } } return ResponseOutput.Ok(); @@ -725,7 +725,7 @@ namespace IRaCIS.Core.Application.Contracts smtp.MessageSent += (sender, args) => { - _ = _trialSiteUserSurveyRepository.UpdateFromQueryAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, InviteState = TrialSiteUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; + _ = _trialSiteUserSurveyRepository.BatchUpdateAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, InviteState = TrialSiteUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; }; @@ -773,12 +773,12 @@ namespace IRaCIS.Core.Application.Contracts if (hasSPMOrCPM) { - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); + await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.CRCSubmitted }); } else { - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); + await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.ToSubmit, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved }); } @@ -786,7 +786,7 @@ namespace IRaCIS.Core.Application.Contracts else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) { - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id, PreliminaryTime = DateTime.Now }); + await _trialSiteSurveyRepository.BatchUpdateAsync(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) @@ -803,7 +803,7 @@ namespace IRaCIS.Core.Application.Contracts await SendInviteEmail(new InviteEmailCommand() { TrialId = trialId, RouteUrl = siteSurvyeSubmit.RouteUrl, UserList = needGenerateList }); - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); + await _trialSiteSurveyRepository.BatchUpdateAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs index 726f35bf0..dcde55b10 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteUserSurveyService.cs @@ -81,7 +81,7 @@ namespace IRaCIS.Core.Application.Contracts return ResponseOutput.NotOk("已锁定,不允许操作"); } - var success = await _trialSiteUserSurveyRepository.DeleteFromQueryAsync(t => t.Id == trialSiteUserSurveyId); + var success = await _trialSiteUserSurveyRepository.BatchDeleteAsync(t => t.Id == trialSiteUserSurveyId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 2e7d5c4a2..520374995 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -88,7 +88,7 @@ namespace IRaCIS.Core.Application [Obsolete] public async Task MakeSignEffective(Guid signId) { - var success = await _repository.UpdateFromQueryAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); + var success = await _repository.BatchUpdateAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); return ResponseOutput.Result(success); } @@ -109,15 +109,15 @@ namespace IRaCIS.Core.Application if (signConfirmDTO.SignCode == ((int)SignEnum.TrialLogicConfim).ToString()) { - await _trialRepository.UpdateFromQueryAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialBasicLogicConfirmed = true }); + await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialBasicLogicConfirmed = true }); } else if (signConfirmDTO.SignCode == ((int)SignEnum.TrialProcessConfim).ToString()) { - await _trialRepository.UpdateFromQueryAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialProcessConfirmed = true }); + await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialProcessConfirmed = true }); } else if (signConfirmDTO.SignCode == ((int)SignEnum.TrialUrgentConfim).ToString()) { - await _trialRepository.UpdateFromQueryAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialUrgentConfirmed = true }); + await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { IsTrialUrgentConfirmed = true }); } else if (signConfirmDTO.SignCode == ((int)SignEnum.TrialQCQuestionConfirm).ToString()) @@ -135,7 +135,7 @@ namespace IRaCIS.Core.Application return ResponseOutput.NotOk("父问题的序号要比子问题序号小,请确认"); } - await _trialRepository.UpdateFromQueryAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { QCQuestionConfirmedTime = DateTime.Now, QCQuestionConfirmedUserId = _userInfo.Id, IsQCQuestionConfirmed = true }); + await _trialRepository.BatchUpdateAsync(t => t.Id == signConfirmDTO.TrialId, u => new Trial() { QCQuestionConfirmedTime = DateTime.Now, QCQuestionConfirmedUserId = _userInfo.Id, IsQCQuestionConfirmed = true }); } @@ -204,12 +204,12 @@ namespace IRaCIS.Core.Application //Paused、 添加工总量 算医生读片中 if (trialStatusStr.Contains(StaticData.TrialCompleted)) { - await _repository.UpdateFromQueryAsync(u => u.TrialId == trialId, e => new Enroll + await _repository.BatchUpdateAsync(u => u.TrialId == trialId, e => new Enroll { EnrollStatus = (int)EnrollStatus.Finished }); - await _trialRepository.UpdateFromQueryAsync(u => u.Id == trialId, s => new Trial { TrialFinishedTime = DateTime.UtcNow.AddHours(8) }); + await _trialRepository.BatchUpdateAsync(u => u.Id == trialId, s => new Trial { TrialFinishedTime = DateTime.UtcNow.AddHours(8) }); } @@ -218,7 +218,7 @@ namespace IRaCIS.Core.Application await _repository.SaveChangesAsync(); - var success = await _repository.UpdateFromQueryAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); + var success = await _repository.BatchUpdateAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); return ResponseOutput.Result(success); @@ -248,10 +248,10 @@ namespace IRaCIS.Core.Application public async Task AbandonTrial(Guid trialId, Guid signId, bool isAbandon) { - await _trialRepository.UpdateFromQueryAsync(t => t.Id == trialId, u => new Trial() { IsDeleted = isAbandon }); + await _trialRepository.BatchUpdateAsync(t => t.Id == trialId, u => new Trial() { IsDeleted = isAbandon }); - var success = await _repository.UpdateFromQueryAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); + var success = await _repository.BatchUpdateAsync(t => t.Id == signId, u => new TrialSign() { IsCompleted = true }); return ResponseOutput.Result(success); @@ -323,7 +323,7 @@ namespace IRaCIS.Core.Application if (trialConfig.IsUrgent) { - await _repository.UpdateFromQueryAsync(t => t.TrialId == trialInfo.Id && t.SubmitState == SubmitStateEnum.Submitted && t.ForwardState < ForwardStateEnum.Forwarded, + await _repository.BatchUpdateAsync(t => t.TrialId == trialInfo.Id && t.SubmitState == SubmitStateEnum.Submitted && t.ForwardState < ForwardStateEnum.Forwarded, s => new SubjectVisit() { IsUrgent = trialConfig.IsUrgent }); } else //之前设置为加急的访视状态不变。后续提交的访视,为不加急。 diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 196f4417d..91d43ff00 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -193,11 +193,11 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{trialExternalUserId:guid}/{isSystemUser:bool}/{systemUserId}")] public async Task DeleteTrialExternalUser(Guid trialExternalUserId, bool isSystemUser, Guid systemUserId) { - var success = await _trialExternalUseRepository.DeleteFromQueryAsync(t => t.Id == trialExternalUserId); + var success = await _trialExternalUseRepository.BatchDeleteAsync(t => t.Id == trialExternalUserId); if (isSystemUser == false) { - await _userRepository.DeleteFromQueryAsync(t => t.Id == systemUserId); + await _userRepository.BatchDeleteAsync(t => t.Id == systemUserId); } return ResponseOutput.Result(success); @@ -263,7 +263,7 @@ namespace IRaCIS.Core.Application.Service smtp.MessageSent += (sender, args) => { - _ = _trialExternalUseRepository.UpdateFromQueryAsync(t => t.Id == userInfo.Id, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, ExpireTime = DateTime.Now.AddDays(7) }).Result; + _ = _trialExternalUseRepository.BatchUpdateAsync(t => t.Id == userInfo.Id, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, ExpireTime = DateTime.Now.AddDays(7) }).Result; }; @@ -343,7 +343,7 @@ namespace IRaCIS.Core.Application.Service if (sysUserInfo.IsFirstAdd) { - await _userRepository.UpdateFromQueryAsync(t => t.Id == sysUserInfo.Id, + await _userRepository.BatchUpdateAsync(t => t.Id == sysUserInfo.Id, u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); } @@ -400,7 +400,7 @@ namespace IRaCIS.Core.Application.Service await smtp.DisconnectAsync(true); } - await _userRepository.UpdateFromQueryAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); } @@ -486,7 +486,7 @@ namespace IRaCIS.Core.Application.Service await _trialSiteUserRepository.AddAsync(new TrialSiteUser() { TrialId = trialId, SiteId = siteId, UserId = userId }); - await _userRepository.UpdateFromQueryAsync(t => t.Id == needUpdate.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateAsync(t => t.Id == needUpdate.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); } @@ -512,7 +512,7 @@ namespace IRaCIS.Core.Application.Service if (sysUserInfo.IsFirstAdd) { - await _userRepository.UpdateFromQueryAsync(t => t.Id == sysUserInfo.Id, + await _userRepository.BatchUpdateAsync(t => t.Id == sysUserInfo.Id, u => new User() { Password = MD5Helper.Md5(verificationCode.ToString()) }); } @@ -661,10 +661,10 @@ namespace IRaCIS.Core.Application.Service { await _repository.AddAsync(new TrialUser() { TrialId = trialId, UserId = (Guid)externalUser.SystemUserId }); - await _trialExternalUseRepository.UpdateFromQueryAsync(t => t.Id == trialExternalUserId, + await _trialExternalUseRepository.BatchUpdateAsync(t => t.Id == trialExternalUserId, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.UserConfirmed }); - await _userRepository.UpdateFromQueryAsync(t => t.Id == externalUser.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateAsync(t => t.Id == externalUser.SystemUserId, u => new User() { Status = UserStateEnum.Enable }); await _userRepository.SaveChangesAsync(); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index ca1d36f79..d0802d7e5 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -166,7 +166,7 @@ namespace IRaCIS.Application.Services if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IQC) { - await _repository.UpdateFromQueryAsync(t => t.CurrentActionUserId == trialUser.UserId && t.TrialId == trialUser.TrialId && t.IsTake, u => new SubjectVisit() { CurrentActionUserId = null, CurrentActionUserExpireTime = null, IsTake = false }); + await _repository.BatchUpdateAsync(t => t.CurrentActionUserId == trialUser.UserId && t.TrialId == trialUser.TrialId && t.IsTake, u => new SubjectVisit() { CurrentActionUserId = null, CurrentActionUserExpireTime = null, IsTake = false }); } } @@ -201,10 +201,10 @@ namespace IRaCIS.Application.Services if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IQC && isDelete) { - await _repository.UpdateFromQueryAsync(t => t.CurrentActionUserId == trialUser.UserId && t.TrialId == trialUser.TrialId && t.IsTake, u => new SubjectVisit() { CurrentActionUserId = null, CurrentActionUserExpireTime = null, IsTake = false }); + await _repository.BatchUpdateAsync(t => t.CurrentActionUserId == trialUser.UserId && t.TrialId == trialUser.TrialId && t.IsTake, u => new SubjectVisit() { CurrentActionUserId = null, CurrentActionUserExpireTime = null, IsTake = false }); } - await _trialUseRepository.UpdateFromQueryAsync(t => t.Id == id, u => new TrialUser() { IsDeleted = isDelete, RemoveTime = isDelete ? DateTime.Now : null }); + await _trialUseRepository.BatchUpdateAsync(t => t.Id == id, u => new TrialUser() { IsDeleted = isDelete, RemoveTime = isDelete ? DateTime.Now : null }); await _repository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 80add9565..bfb18ce21 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -210,7 +210,7 @@ namespace IRaCIS.Application.Services //删除中间表 Title对应的记录 - await _repository.DeleteFromQueryAsync(t => t.TrialId == updateModel.Id); + await _repository.BatchDeleteAsync(t => t.TrialId == updateModel.Id); //重新插入新的 Title记录 @@ -245,7 +245,7 @@ namespace IRaCIS.Application.Services switch (newState) { case (int)TrialExpedited.ExpeditedIn24H: - await _repository.UpdateFromQueryAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() + await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() { TimepointIn24H = u.Timepoint, AdjudicationIn24H = u.Adjudication, @@ -254,7 +254,7 @@ namespace IRaCIS.Application.Services }); break; case (int)TrialExpedited.ExpeditedIn48H: - await _repository.UpdateFromQueryAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() + await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() { TimepointIn48H = u.Timepoint, AdjudicationIn48H = u.Adjudication, @@ -275,7 +275,7 @@ namespace IRaCIS.Application.Services switch (newState) { case (int)TrialExpedited.None: - await _repository.UpdateFromQueryAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() + await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() { Timepoint = u.TimepointIn24H, Adjudication = u.AdjudicationIn24H, @@ -284,7 +284,7 @@ namespace IRaCIS.Application.Services }); break; case (int)TrialExpedited.ExpeditedIn48H: - await _repository.UpdateFromQueryAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() + await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() { TimepointIn48H = u.TimepointIn24H, AdjudicationIn48H = u.AdjudicationIn24H, @@ -306,7 +306,7 @@ namespace IRaCIS.Application.Services switch (newState) { case (int)TrialExpedited.None: - await _repository.UpdateFromQueryAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() + await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() { Timepoint = u.TimepointIn48H, Adjudication = u.AdjudicationIn48H, @@ -315,7 +315,7 @@ namespace IRaCIS.Application.Services }); break; case (int)TrialExpedited.ExpeditedIn24H: - await _repository.UpdateFromQueryAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() + await _repository.BatchUpdateAsync(t => t.IsLock == false && t.TrialId == trialId, u => new Workload() { TimepointIn24H = u.TimepointIn48H, AdjudicationIn24H = u.AdjudicationIn48H, @@ -370,9 +370,9 @@ namespace IRaCIS.Application.Services if (await _trialUserRepository.CountAsync(t => t.TrialId == trialId) == 1) { - var success1 = await _repository.DeleteFromQueryAsync(o => o.Id == trialId) || - await _repository.DeleteFromQueryAsync(t => t.TrialId == trialId) || - await _repository.DeleteFromQueryAsync(t => t.TrialId == trialId); + var success1 = await _repository.BatchDeleteAsync(o => o.Id == trialId) || + await _repository.BatchDeleteAsync(t => t.TrialId == trialId) || + await _repository.BatchDeleteAsync(t => t.TrialId == trialId); return ResponseOutput.Result(success1); } @@ -382,10 +382,10 @@ namespace IRaCIS.Application.Services { return ResponseOutput.NotOk("该Trial下面有参与者,无法删除"); } - var success = await _repository.DeleteFromQueryAsync(o => o.Id == trialId) || - await _repository.DeleteFromQueryAsync(t => t.TrialId == trialId) || - await _repository.DeleteFromQueryAsync(t => t.TrialId == trialId) || - await _repository.DeleteFromQueryAsync(t => t.TrialId == trialId); + var success = await _repository.BatchDeleteAsync(o => o.Id == trialId) || + await _repository.BatchDeleteAsync(t => t.TrialId == trialId) || + await _repository.BatchDeleteAsync(t => t.TrialId == trialId) || + await _repository.BatchDeleteAsync(t => t.TrialId == trialId); return ResponseOutput.Result(success); @@ -434,9 +434,9 @@ namespace IRaCIS.Application.Services } } - await _trialRepository.UpdateFromQueryAsync(u => u.Id == trialId, t => new Trial() { VisitPlanConfirmed = confirmOrCancel }); + await _trialRepository.BatchUpdateAsync(u => u.Id == trialId, t => new Trial() { VisitPlanConfirmed = confirmOrCancel }); - await _repository.UpdateFromQueryAsync(u => u.Id == trialId, t => new VisitStage() { IsConfirmed = true }); + await _repository.BatchUpdateAsync(u => u.Id == trialId, t => new VisitStage() { IsConfirmed = true }); return ResponseOutput.Ok(); @@ -484,7 +484,7 @@ namespace IRaCIS.Application.Services EnrollStatus = status, OptUserType = (int)SystemUserType.DoctorUser, }); - return ResponseOutput.Result(await _repository.UpdateFromQueryAsync(u => u.TrialId == trialId && u.DoctorId == _userInfo.Id, e => new Enroll + return ResponseOutput.Result(await _repository.BatchUpdateAsync(u => u.TrialId == trialId && u.DoctorId == _userInfo.Id, e => new Enroll { EnrollStatus = status })); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index 4d04c170b..0cabe979e 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -299,7 +299,7 @@ namespace IRaCIS.Core.Application.Services { - var isSuccess = await _trialSiteUserRepository.UpdateFromQueryAsync(u => u.Id == id, u => new TrialSiteUser() + var isSuccess = await _trialSiteUserRepository.BatchUpdateAsync(u => u.Id == id, u => new TrialSiteUser() { IsDeleted = isDelete, DeletedTime = isDelete ? DateTime.Now : null }); return ResponseOutput.Ok(isSuccess); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs index b6daeece3..360eae1cf 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialUserPreparationService.cs @@ -100,7 +100,7 @@ namespace IRaCIS.Core.Application.Service await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId }); - await _trialExternalUseRepository.UpdateFromQueryAsync(t => t.TrialId == trialId && t.SystemUserId == userId, + await _trialExternalUseRepository.BatchUpdateAsync(t => t.TrialId == trialId && t.SystemUserId == userId, u => new TrialExternalUser() { InviteState = TrialExternalUserStateEnum.UserConfirmed }); @@ -122,7 +122,7 @@ namespace IRaCIS.Core.Application.Service } } - await _userRepository.UpdateFromQueryAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); + await _userRepository.BatchUpdateAsync(t => t.Id == userId, u => new User() { Status = UserStateEnum.Enable }); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs index f73f8cb55..e5971fb37 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs @@ -70,10 +70,10 @@ namespace IRaCIS.Application.Services if (mapedSubject.SiteId != subjectCommand.SiteId) { - await _repository.UpdateFromQueryAsync(t => t.SubjectId == mapedSubject.Id, + await _repository.BatchUpdateAsync(t => t.SubjectId == mapedSubject.Id, u => new SubjectVisit() { SiteId = mapedSubject.SiteId }); - await _repository.UpdateFromQueryAsync(t => t.SubjectId == mapedSubject.Id, + await _repository.BatchUpdateAsync(t => t.SubjectId == mapedSubject.Id, u => new DicomStudy() { SiteId = mapedSubject.SiteId }); @@ -210,13 +210,13 @@ namespace IRaCIS.Application.Services sv.IsFinalVisit = true; //末次访视后的 访视设置为不可用 - await _repository.UpdateFromQueryAsync(t => t.SubjectId == subjectStatusChangeCommand.SubjectId && t.VisitNum > sv.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); + await _repository.BatchUpdateAsync(t => t.SubjectId == subjectStatusChangeCommand.SubjectId && t.VisitNum > sv.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); } //将受试者未执行的 设置为不可用 - await _repository.UpdateFromQueryAsync(t => t.SubjectId == subject.Id && t.VisitExecuted == VisitExecutedEnum.UnExecuted, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); + await _repository.BatchUpdateAsync(t => t.SubjectId == subject.Id && t.VisitExecuted == VisitExecutedEnum.UnExecuted, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); } else { @@ -263,8 +263,8 @@ namespace IRaCIS.Application.Services return ResponseOutput.NotOk("This subject has executed a visit with uploading study images,and couldn't be deleted."); } - var isSuccess = await _subjectRepository.DeleteFromQueryAsync(u => u.Id == id); - await _repository.DeleteFromQueryAsync(u => u.SubjectId == id); + var isSuccess = await _subjectRepository.BatchDeleteAsync(u => u.Id == id); + await _repository.BatchDeleteAsync(u => u.SubjectId == id); var subvisit = await _repository.GetQueryable().Where(x=>x.SubjectId==id).ToListAsync(); List datas = new List(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index 8ca7c0f5e..3d5205019 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -96,7 +96,7 @@ namespace IRaCIS.Core.Application.Services subject.Status = SubjectStatus.OutOfVisit; //末次访视后的 访视设置为不可用 - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.SubjectId == svCommand.SubjectId && t.VisitNum > svCommand.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); + await _subjectVisitRepository.BatchUpdateAsync(t => t.SubjectId == svCommand.SubjectId && t.VisitNum > svCommand.VisitNum, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Unavailable }); } else @@ -104,7 +104,7 @@ namespace IRaCIS.Core.Application.Services //回退 subject.Status = SubjectStatus.OnVisit; - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.SubjectId == svCommand.SubjectId && t.VisitExecuted == VisitExecutedEnum.Unavailable, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.UnExecuted }); + await _subjectVisitRepository.BatchUpdateAsync(t => t.SubjectId == svCommand.SubjectId && t.VisitExecuted == VisitExecutedEnum.Unavailable, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.UnExecuted }); } if (svCommand.IsLostVisit && svCommand.Id == null) @@ -145,7 +145,7 @@ namespace IRaCIS.Core.Application.Services if (svCommand.IsEnrollmentConfirm != null) { - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.SubjectId == svCommand.SubjectId && t.IsBaseLine , u => new SubjectVisit() { IsEnrollmentConfirm = svCommand.IsEnrollmentConfirm.Value }); + await _subjectVisitRepository.BatchUpdateAsync(t => t.SubjectId == svCommand.SubjectId && t.IsBaseLine , u => new SubjectVisit() { IsEnrollmentConfirm = svCommand.IsEnrollmentConfirm.Value }); //needDealEntity.IsUrgent = true; @@ -209,7 +209,7 @@ namespace IRaCIS.Core.Application.Services [HttpPut("{trialId:guid}/{subjectVisitId:guid}/{isUrgent:bool}")] public async Task SetSubjectVisitUrgent(Guid subjectVisitId, bool isUrgent) { - await _subjectVisitRepository.UpdateFromQueryAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { IsUrgent = isUrgent }); + await _subjectVisitRepository.BatchUpdateAsync(t => t.Id == subjectVisitId, u => new SubjectVisit() { IsUrgent = isUrgent }); return ResponseOutput.Ok(); } @@ -232,7 +232,7 @@ namespace IRaCIS.Core.Application.Services { return ResponseOutput.NotOk("This visit is OutPlanPreviousVisitId and couldn't be deleted."); } - return ResponseOutput.Result(await _repository.DeleteFromQueryAsync(s => s.Id == id)); + return ResponseOutput.Result(await _repository.BatchDeleteAsync(s => s.Id == id)); } /// @@ -245,7 +245,7 @@ namespace IRaCIS.Core.Application.Services [TypeFilter(typeof(TrialResourceFilter))] public async Task SetSVExecuted(Guid subjectVisitId) { - return ResponseOutput.Result(await _subjectVisitRepository.UpdateFromQueryAsync(s => s.Id == subjectVisitId, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Executed })); + return ResponseOutput.Result(await _subjectVisitRepository.BatchUpdateAsync(s => s.Id == subjectVisitId, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.Executed })); } diff --git a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs index 1c929e564..cabfc3ecf 100644 --- a/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs +++ b/IRaCIS.Core.Application/Service/Visit/VisitPlanService.cs @@ -196,7 +196,7 @@ namespace IRaCIS.Application.Services //}); //更新项目访视计划状态为未确认 - await _trialRepository.UpdateFromQueryAsync(u => u.Id == visitPlan.TrialId, t => new Trial() { VisitPlanConfirmed = false }); + await _trialRepository.BatchUpdateAsync(u => u.Id == visitPlan.TrialId, t => new Trial() { VisitPlanConfirmed = false }); await _repository.SaveChangesAsync(); @@ -292,9 +292,9 @@ namespace IRaCIS.Application.Services await _inspectionService.AddListInspectionRecordAsync(datas); - await _repository.DeleteFromQueryAsync(t => t.TrialId == visitPlan.TrialId && t.VisitName == visitPlan.VisitName); + await _repository.BatchDeleteAsync(t => t.TrialId == visitPlan.TrialId && t.VisitName == visitPlan.VisitName); - var result = await _visitStageRepository.DeleteFromQueryAsync(u => u.Id == id); + var result = await _visitStageRepository.BatchDeleteAsync(u => u.Id == id); return ResponseOutput.Result(result); } @@ -333,7 +333,7 @@ namespace IRaCIS.Application.Services var addvisitStages = await _visitStageRepository.Where(x => !x.IsHaveFirstConfirmed&&x.TrialId== trialId).ToListAsync(); //更新项目访视计划状态为已确认 - await _trialRepository.UpdateFromQueryAsync(u => u.Id == trialId, t => new Trial() { VisitPlanConfirmed = true }); + await _trialRepository.BatchUpdateAsync(u => u.Id == trialId, t => new Trial() { VisitPlanConfirmed = true }); //找到访视计划修改的Item var changedList = await _visitStageRepository.Where(t => t.TrialId == trialId && t.IsConfirmed == false) @@ -358,7 +358,7 @@ namespace IRaCIS.Application.Services }); //访视计划 整体状态变更为 确认 - await _visitStageRepository.UpdateFromQueryAsync(u => u.TrialId == trialId, t => new VisitStage() { IsConfirmed = true ,IsHaveFirstConfirmed = true}); + await _visitStageRepository.BatchUpdateAsync(u => u.TrialId == trialId, t => new VisitStage() { IsConfirmed = true ,IsHaveFirstConfirmed = true}); var stat = new VisitPlanInfluenceStat() { TrialId = trialId }; @@ -509,7 +509,7 @@ namespace IRaCIS.Application.Services //变更某一访视计划Item 受试者访视相关字段 - await _repository.UpdateFromQueryAsync(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id, k => new SubjectVisit() + await _repository.BatchUpdateAsync(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id, k => new SubjectVisit() { IsBaseLine = changedItem.IsBaseLine, VisitName = changedItem.VisitName, diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs index a50053c43..df2050480 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs @@ -60,7 +60,7 @@ namespace IRaCIS.Application.Services if (attachmentViewModel.Id != Guid.Empty) { - await _attachmentRepository.DeleteFromQueryAsync(t => t.Id == attachmentViewModel.Id); + await _attachmentRepository.BatchDeleteAsync(t => t.Id == attachmentViewModel.Id); } var attach = _mapper.Map(attachmentViewModel); @@ -83,8 +83,8 @@ namespace IRaCIS.Application.Services [TypeFilter(typeof(TrialResourceFilter))] public async Task DeleteReviewerAckSOW(Guid trialId, Guid doctorId, Guid attachmentId) { - var success1 = await _attachmentRepository.DeleteFromQueryAsync(a => a.Id == attachmentId); - var success2 = await _enrollRepository.UpdateFromQueryAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => + var success1 = await _attachmentRepository.BatchDeleteAsync(a => a.Id == attachmentId); + var success2 = await _enrollRepository.BatchUpdateAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => new Enroll() { AttachmentId = Guid.Empty @@ -100,7 +100,7 @@ namespace IRaCIS.Application.Services [TypeFilter(typeof(TrialResourceFilter))] public async Task UpdateReviewerReadingType(Guid trialId, Guid doctorId, int type) { - var success2 = await _enrollRepository.UpdateFromQueryAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => + var success2 = await _enrollRepository.BatchUpdateAsync(t => t.TrialId == trialId && t.DoctorId == doctorId, u => new Enroll() { ReviewerReadingType = type @@ -625,7 +625,7 @@ namespace IRaCIS.Application.Services await _doctorWorkloadRepository.AddAsync(workLoad); - await _enrollRepository.UpdateFromQueryAsync( + await _enrollRepository.BatchUpdateAsync( t => t.DoctorId == workLoadAddOrUpdateModel.DoctorId && t.TrialId == workLoadAddOrUpdateModel.TrialId, u => new Enroll() { EnrollStatus = (int)EnrollStatus.DoctorReading, @@ -649,7 +649,7 @@ namespace IRaCIS.Application.Services } - var success = await _doctorWorkloadRepository.UpdateFromQueryAsync(t => t.Id == workLoadAddOrUpdateModel.Id, + var success = await _doctorWorkloadRepository.BatchUpdateAsync(t => t.Id == workLoadAddOrUpdateModel.Id, u => new Workload() { Timepoint = workLoadAddOrUpdateModel.Timepoint, @@ -681,7 +681,7 @@ namespace IRaCIS.Application.Services /// public async Task DeleteWorkload(Guid workloadId) { - return ResponseOutput.Result(await _doctorWorkloadRepository.DeleteFromQueryAsync(t => t.Id == workloadId)); + return ResponseOutput.Result(await _doctorWorkloadRepository.BatchDeleteAsync(t => t.Id == workloadId)); } /// diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index ee20dd47d..3eda5cd9d 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -11,9 +11,9 @@ namespace IRaCIS.Application.Services public class TestService : BaseService { private readonly IRepository _dicRepository; - private readonly IRepository _trialRepository; + private readonly IRepository _trialRepository; - public TestService(IRepository dicRepository,IRepository trialRepository) + public TestService(IRepository dicRepository,IRepository trialRepository) { _dicRepository = dicRepository; _trialRepository = trialRepository; @@ -27,19 +27,19 @@ namespace IRaCIS.Application.Services var c = _dicRepository.Where(t => t.ParentId != null).Select(t => t.MappedValue).First(); CultureInfo culture = CultureInfo.CurrentUICulture; - //var dd= _dicRepository.UpdatePartialFields(Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"), - // u => new Dictionary() { ParentId = null, Code = "test" }, true).Result; + var dd = _dicRepository.UpdatePartialFields(Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"), + u => new Dictionary() { ParentId = null, Code = "test" }, true).Result; var aaaa = _dicRepository.BatchDeleteAsync(t => t.Id == Guid.Empty).Result; //var ggggg = _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"), u=>new Dictionary(){Code = "test"}).Result; - var ddd = _dicRepository.BatchUpdateAsync(t => t.Id == Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"), - u => new Dictionary() { ParentId = null, Code = "test" }).Result; + //var ddd = _dicRepository.BatchUpdateAsync(t => t.Id == Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"), + // u => new Dictionary() { /*ParentId = null,*/ Code = "test" }).Result; var aaaaa= _trialRepository.BatchUpdateAsync(t => t.Id == Guid.Empty, - u => new Trial { TrialCode = "test" }).Result; + u => new SubjectVisit() { CurrentActionUserId = null }).Result; //var d = _dicRepository.UpdateFromDTOAsync(new AddOrEditBasicDic() { Id = Guid.Parse("60d86683-c33b-4349-b672-08da1e91b622"), ParentId = null, ChildGroup = null, Code = null }, true, true).Result; diff --git a/IRaCIS.Core.IdentityServer4/Startup.cs b/IRaCIS.Core.IdentityServer4/Startup.cs index eaf0c5a1d..d23c84c1d 100644 --- a/IRaCIS.Core.IdentityServer4/Startup.cs +++ b/IRaCIS.Core.IdentityServer4/Startup.cs @@ -12,7 +12,6 @@ using IRaCIS.Core.IdentityServer4.Account; using IdentityServer4.Configuration; using Microsoft.EntityFrameworkCore; using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Infra.EFCore.AuthUser; using IdentityServer4.Services; using ReturnUrlParser = IRaCIS.Core.IdentityServer4.Account.ReturnUrlParser; using Microsoft.AspNetCore.Http; @@ -47,7 +46,6 @@ namespace IRaCIS.Core.IdentityServer4 }, ServiceLifetime.Scoped); - services.AddScoped(); services.AddTransient(); services.AddScoped(typeof(IRepository<>), typeof(Repository<>)); diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index b1781c0f5..3fd87e046 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -37,8 +37,6 @@ namespace IRaCIS.Core.Infra.EFCore optionsBuilder.UseLoggerFactory(MyLoggerFactory) .ReplaceService(); - optionsBuilder.UseBatchEF_MSSQL(); - //var config = new ConfigurationBuilder() // .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true).Build(); //connectionString = config.GetSection("ConnectionStrings:RemoteNew").Value; diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index fa3b4d973..e67fa9b60 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -27,7 +27,6 @@ - diff --git a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs index 1d09171d0..aea078481 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/ICommandRepository.cs @@ -23,10 +23,8 @@ namespace IRaCIS.Core.Infra.EFCore Task UpdatePartialFields(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify); - Task BatchUpdateAsync(Expression> where, - Expression> updateFactory); - Task BatchDeleteAsync(Expression> deleteFilter); + Task BatchUpdateAsync(Expression> where, Expression> updateFactory); } @@ -56,8 +54,7 @@ namespace IRaCIS.Core.Infra.EFCore Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); Task DeleteManyAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default); - Task DeleteFromQueryAsync(Expression> deleteFilter) ; - Task UpdateFromQueryAsync(Expression> where, Expression> updateFactory); + } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs index 77582347c..aa378cb31 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/IRepository.cs @@ -11,6 +11,8 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using EFCore.BulkExtensions; +using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Infra.EFCore { @@ -59,9 +61,9 @@ namespace IRaCIS.Core.Infra.EFCore Task SaveChangesAsync(); - Task DeleteFromQueryAsync(Expression> deleteFilter) where T : Entity; + Task BatchDeleteAsync(Expression> deleteFilter) where T : Entity; - Task UpdateFromQueryAsync(Expression> where, Expression> updateFactory) where T : Entity; + Task BatchUpdateAsync(Expression> where, Expression> updateFactory) where T : Entity; } public class Repository : IRepository @@ -70,10 +72,13 @@ namespace IRaCIS.Core.Infra.EFCore public IMapper _mapper { get; set; } - public Repository(IRaCISDBContext dbContext, IMapper mapper) + public IUserInfo _userInfo { get; set; } + + public Repository(IRaCISDBContext dbContext, IMapper mapper, IUserInfo userInfo) { _dbContext = dbContext; _mapper = mapper; + _userInfo = userInfo; } /// @@ -396,18 +401,32 @@ namespace IRaCIS.Core.Infra.EFCore #endregion - public async Task DeleteFromQueryAsync(Expression> deleteFilter) where T : Entity + public async Task BatchDeleteAsync(Expression> deleteFilter) where T : Entity { if (deleteFilter == null) throw new ArgumentNullException(nameof(deleteFilter)); - return await _dbContext.Set().AsNoTracking().Where(deleteFilter).DeleteFromQueryAsync().ConfigureAwait(false) > 0; + return await _dbContext.Set().AsNoTracking().Where(deleteFilter).BatchDeleteAsync().ConfigureAwait(false) > 0; } - public async Task UpdateFromQueryAsync(Expression> whereFilter, Expression> updateFactory) where T : Entity + public async Task BatchUpdateAsync(Expression> whereFilter, Expression> updateFactory) where T : Entity { if (whereFilter == null) throw new ArgumentNullException(nameof(whereFilter)); - return await _dbContext.Set().AsNoTracking().IgnoreQueryFilters().Where(whereFilter).UpdateFromQueryAsync(updateFactory).ConfigureAwait(false) > 0; + var bindings = ((MemberInitExpression)updateFactory.Body).Bindings.ToList(); + + if (typeof(IAuditUpdate).IsAssignableFrom(typeof(T))) + { + + bindings.Add(Expression.Bind(typeof(T).GetMember(nameof(IAuditUpdate.UpdateTime))[0], Expression.Constant(DateTime.Now))); + bindings.Add(Expression.Bind(typeof(TR).GetMember(nameof(IAuditUpdate.UpdateUserId))[0], Expression.Constant(_userInfo.Id))); + } + + + var member = Expression.MemberInit(Expression.New(typeof(T)), bindings); + + var factory = Expression.Lambda>(member, Expression.Parameter(typeof(T), "x")); + + return await _dbContext.Set().AsNoTracking().IgnoreQueryFilters().Where(whereFilter).BatchUpdateAsync(updateFactory).ConfigureAwait(false) > 0; } } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index f53add7aa..82e7f41c5 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -13,6 +13,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; using AutoMapper.QueryableExtensions; using EFCore.BulkExtensions; +using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure.Extention; using Microsoft.Data.SqlClient; @@ -28,11 +29,13 @@ namespace IRaCIS.Core.Infra.EFCore public DbSet _dbSet => _dbContext.Set(); + public IUserInfo _userInfo { get; set; } - public Repository(IRaCISDBContext dbContext, IMapper mapper) + public Repository(IRaCISDBContext dbContext, IMapper mapper,IUserInfo userInfo) { _dbContext = dbContext; _mapper = mapper; + _userInfo = userInfo; } #region 异步部分 @@ -155,6 +158,16 @@ namespace IRaCIS.Core.Infra.EFCore } + /// + /// 用前端传递的视图模型字段,更新,同时返回数据库该条记录的原始信息,方便对比某些字段是否更改,进行相应的逻辑操作 + /// + /// + /// + /// + /// + /// + /// + /// public async Task UpdateFromDTOAsync(TFrom from, bool autoSave = false, bool ignoreDtoNullProperty = true, params EntityVerifyExp[] verify) { @@ -180,9 +193,10 @@ namespace IRaCIS.Core.Infra.EFCore // Guid?属性 为null 时 映射到 Guid 时 默认会变成 Guid.Empty if (ignoreDtoNullProperty) { + var dbEntityProp = typeof(TEntity).GetProperties(); foreach (var propertyInfo in from.GetType().GetProperties()) { - if (propertyInfo.GetValue(from) == null) + if (propertyInfo.GetValue(from) == null && dbEntityProp.Any(t=>t.Name== propertyInfo.Name)) { _dbContext.Entry(dbEntity).Property(propertyInfo.Name).IsModified = false; } @@ -196,46 +210,6 @@ namespace IRaCIS.Core.Infra.EFCore } - /// - /// 通过主键id 和表达式树 更新部分字段 例如 Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"),u => new Dictionary() { ParentId = null, Code = "test" } 默认会去处理更新更新人 更新时间 - /// - /// - /// - /// - /// - /// - public async Task UpdatePartialFields(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify) - { - await EntityVerifyAsync(false, verify, id); - - var entity = new TEntity() { Id = id }; - - var entityEntry = _dbContext.Entry(entity); - entityEntry.State = EntityState.Detached; - - - Func func = updateFactory.Compile(); - - List list = ((MemberInitExpression)updateFactory.Body).Bindings.Select((Func)(_param1 => _param1.Member.Name)).Select((Func)(_param1 => (PropertyInfo)typeof(TEntity).GetProperty(_param1, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))).ToList(); - - - TEntity applyObj = func(entity); - - foreach (PropertyInfo prop in list) - { - object value = prop.GetValue((object)applyObj); - prop.SetValue((object)entity, value); - - _dbContext.Entry(entity).Property(prop.Name).IsModified = true; - } - - - await SaveChangesAsync(autoSave); - - return entityEntry.Entity; - } - - private async Task SaveChangesAsync(bool autoSave) { if (autoSave) @@ -248,8 +222,65 @@ namespace IRaCIS.Core.Infra.EFCore } } + /// + /// 通过主键id 和表达式树 更新部分字段 例如 Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584"),u => new Dictionary() { ParentId = null, Code = "test" } 默认会去处理更新更新人 更新时间 + /// + /// + /// + /// + /// + /// + public async Task UpdatePartialFields(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify) + { + await EntityVerifyAsync(false, verify, id); + + var entity = new TEntity() { Id = id }; + + var entityEntry = _dbContext.Entry(entity); + + entityEntry.State = EntityState.Detached; + + + List list = ((MemberInitExpression)updateFactory.Body).Bindings.Select(mb => mb.Member.Name) + .Select(propName => typeof(TEntity).GetProperty(propName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)).ToList(); + + Func func = updateFactory.Compile(); + + TEntity applyObj = func(entity); + + foreach (PropertyInfo prop in list) + { + object value = prop.GetValue((object)applyObj); + prop.SetValue((object)entity, value); + + _dbContext.Entry(entity).Property(prop.Name).IsModified = true; + } + + + await SaveChangesAsync(autoSave); + + return entityEntry.Entity; + + #region Test + + + //updateFactory.Compile()(entity); + + //List propNameList = ((MemberInitExpression)updateFactory.Body).Bindings.Select(mb => mb.Member.Name).ToList(); + + //foreach (string propName in propNameList) + //{ + // _dbContext.Entry(entity).Property(propName).IsModified = true; + //} + + #endregion + } + + + /// /// 部分字段更新 (只更新传递的字段名 new[] {nameof(User.Name), nameof(User.Age)) + /// new Dictionary() { ParentId = null, Code = "test",Id=Guid.Parse("8a90c96e-0776-4f7b-82a6-18933d339584")},new[] {nameof(Dictionary.Name), nameof(Dictionary.Age)) /// /// /// 更新的字段数组 @@ -501,16 +532,6 @@ namespace IRaCIS.Core.Infra.EFCore return whereLambda == null ? await query.AsNoTracking().CountAsync() : await query.AsNoTracking().CountAsync(whereLambda); } - // Z.EntityFramework.Plus.EFCore - public async Task DeleteFromQueryAsync(Expression> deleteFilter) - { - return await _dbSet.IgnoreQueryFilters().Where(deleteFilter).DeleteFromQueryAsync() > 0; - } - - public async Task UpdateFromQueryAsync(Expression> where, Expression> updateFactory) - { - return await _dbSet.IgnoreQueryFilters().Where(where).UpdateFromQueryAsync(updateFactory) > 0; - } public async Task BatchDeleteAsync(Expression> deleteFilter) @@ -523,7 +544,27 @@ namespace IRaCIS.Core.Infra.EFCore Expression> updateFactory) { - return await _dbSet.IgnoreQueryFilters().Where(where).BatchUpdateAsync(updateFactory) > 0; + //return await _dbSet.IgnoreQueryFilters().Where(where).BatchUpdateAsync(updateFactory) > 0; + + var bindings = ((MemberInitExpression)updateFactory.Body).Bindings.ToList(); + + if (typeof(IAuditUpdate).IsAssignableFrom(typeof(TEntity))) + { + + bindings.Add(Expression.Bind(typeof(TEntity).GetMember(nameof(IAuditUpdate.UpdateTime))[0], Expression.Constant(DateTime.Now))); + bindings.Add(Expression.Bind(typeof(TEntity).GetMember(nameof(IAuditUpdate.UpdateUserId))[0], Expression.Constant(_userInfo.Id))); + } + + + var member = Expression.MemberInit(Expression.New(typeof(TEntity)), bindings); + + var factory = Expression.Lambda>(member, Expression.Parameter(typeof(TEntity), "x")); + + + return await _dbSet.IgnoreQueryFilters().Where(where).BatchUpdateAsync(factory) > 0; + + + } @@ -570,6 +611,16 @@ namespace IRaCIS.Core.Infra.EFCore // return await builder.Where(where).ExecuteAsync()>0; //} + //// Z.EntityFramework.Plus.EFCore + //public async Task BatchDeleteAsync(Expression> deleteFilter) + //{ + // return await _dbSet.IgnoreQueryFilters().Where(deleteFilter).DeleteFromQueryAsync() > 0; + //} + + //public async Task BatchUpdateAsync(Expression> where, Expression> updateFactory) + //{ + // return await _dbSet.IgnoreQueryFilters().Where(where).UpdateFromQueryAsync(updateFactory) > 0; + //} #endregion