修改仓储批量更新和批量删除方法
This commit is contained in:
@@ -88,7 +88,7 @@ namespace IRaCIS.Core.Application
|
||||
[Obsolete]
|
||||
public async Task<IResponseOutput> MakeSignEffective(Guid signId)
|
||||
{
|
||||
var success = await _repository.UpdateFromQueryAsync<TrialSign>(t => t.Id == signId, u => new TrialSign() { IsCompleted = true });
|
||||
var success = await _repository.BatchUpdateAsync<TrialSign>(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<Enroll>(u => u.TrialId == trialId, e => new Enroll
|
||||
await _repository.BatchUpdateAsync<Enroll>(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<TrialSign>(t => t.Id == signId, u => new TrialSign() { IsCompleted = true });
|
||||
var success = await _repository.BatchUpdateAsync<TrialSign>(t => t.Id == signId, u => new TrialSign() { IsCompleted = true });
|
||||
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
@@ -248,10 +248,10 @@ namespace IRaCIS.Core.Application
|
||||
public async Task<IResponseOutput> 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<TrialSign>(t => t.Id == signId, u => new TrialSign() { IsCompleted = true });
|
||||
var success = await _repository.BatchUpdateAsync<TrialSign>(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<SubjectVisit>(t => t.TrialId == trialInfo.Id && t.SubmitState == SubmitStateEnum.Submitted && t.ForwardState < ForwardStateEnum.Forwarded,
|
||||
await _repository.BatchUpdateAsync<SubjectVisit>(t => t.TrialId == trialInfo.Id && t.SubmitState == SubmitStateEnum.Submitted && t.ForwardState < ForwardStateEnum.Forwarded,
|
||||
s => new SubjectVisit() { IsUrgent = trialConfig.IsUrgent });
|
||||
}
|
||||
else //之前设置为加急的访视状态不变。后续提交的访视,为不加急。
|
||||
|
||||
@@ -193,11 +193,11 @@ namespace IRaCIS.Core.Application.Service
|
||||
[HttpDelete("{trialExternalUserId:guid}/{isSystemUser:bool}/{systemUserId}")]
|
||||
public async Task<IResponseOutput> 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();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace IRaCIS.Application.Services
|
||||
|
||||
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IQC)
|
||||
{
|
||||
await _repository.UpdateFromQueryAsync<SubjectVisit>(t => t.CurrentActionUserId == trialUser.UserId && t.TrialId == trialUser.TrialId && t.IsTake, u => new SubjectVisit() { CurrentActionUserId = null, CurrentActionUserExpireTime = null, IsTake = false });
|
||||
await _repository.BatchUpdateAsync<SubjectVisit>(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<SubjectVisit>(t => t.CurrentActionUserId == trialUser.UserId && t.TrialId == trialUser.TrialId && t.IsTake, u => new SubjectVisit() { CurrentActionUserId = null, CurrentActionUserExpireTime = null, IsTake = false });
|
||||
await _repository.BatchUpdateAsync<SubjectVisit>(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();
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace IRaCIS.Application.Services
|
||||
|
||||
|
||||
//删除中间表 Title对应的记录
|
||||
await _repository.DeleteFromQueryAsync<TrialDictionary>(t => t.TrialId == updateModel.Id);
|
||||
await _repository.BatchDeleteAsync<TrialDictionary>(t => t.TrialId == updateModel.Id);
|
||||
|
||||
//重新插入新的 Title记录
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace IRaCIS.Application.Services
|
||||
switch (newState)
|
||||
{
|
||||
case (int)TrialExpedited.ExpeditedIn24H:
|
||||
await _repository.UpdateFromQueryAsync<Workload>(t => t.IsLock == false && t.TrialId == trialId, u => new Workload()
|
||||
await _repository.BatchUpdateAsync<Workload>(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<Workload>(t => t.IsLock == false && t.TrialId == trialId, u => new Workload()
|
||||
await _repository.BatchUpdateAsync<Workload>(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<Workload>(t => t.IsLock == false && t.TrialId == trialId, u => new Workload()
|
||||
await _repository.BatchUpdateAsync<Workload>(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<Workload>(t => t.IsLock == false && t.TrialId == trialId, u => new Workload()
|
||||
await _repository.BatchUpdateAsync<Workload>(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<Workload>(t => t.IsLock == false && t.TrialId == trialId, u => new Workload()
|
||||
await _repository.BatchUpdateAsync<Workload>(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<Workload>(t => t.IsLock == false && t.TrialId == trialId, u => new Workload()
|
||||
await _repository.BatchUpdateAsync<Workload>(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<Trial>(o => o.Id == trialId) ||
|
||||
await _repository.DeleteFromQueryAsync<TrialUser>(t => t.TrialId == trialId) ||
|
||||
await _repository.DeleteFromQueryAsync<TrialDictionary>(t => t.TrialId == trialId);
|
||||
var success1 = await _repository.BatchDeleteAsync<Trial>(o => o.Id == trialId) ||
|
||||
await _repository.BatchDeleteAsync<TrialUser>(t => t.TrialId == trialId) ||
|
||||
await _repository.BatchDeleteAsync<TrialDictionary>(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<Trial>(o => o.Id == trialId) ||
|
||||
await _repository.DeleteFromQueryAsync<TrialUser>(t => t.TrialId == trialId) ||
|
||||
await _repository.DeleteFromQueryAsync<TrialDictionary>(t => t.TrialId == trialId) ||
|
||||
await _repository.DeleteFromQueryAsync<TrialSiteUser>(t => t.TrialId == trialId);
|
||||
var success = await _repository.BatchDeleteAsync<Trial>(o => o.Id == trialId) ||
|
||||
await _repository.BatchDeleteAsync<TrialUser>(t => t.TrialId == trialId) ||
|
||||
await _repository.BatchDeleteAsync<TrialDictionary>(t => t.TrialId == trialId) ||
|
||||
await _repository.BatchDeleteAsync<TrialSiteUser>(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<VisitStage>(u => u.Id == trialId, t => new VisitStage() { IsConfirmed = true });
|
||||
await _repository.BatchUpdateAsync<VisitStage>(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<Enroll>(u => u.TrialId == trialId && u.DoctorId == _userInfo.Id, e => new Enroll
|
||||
return ResponseOutput.Result(await _repository.BatchUpdateAsync<Enroll>(u => u.TrialId == trialId && u.DoctorId == _userInfo.Id, e => new Enroll
|
||||
{
|
||||
EnrollStatus = status
|
||||
}));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user