Merge branch 'master' of http://192.168.1.2:8033/IRaCIS_Core_Api
commit
4831d6bd07
|
@ -938,6 +938,13 @@
|
|||
<member name="M:IRaCIS.Core.Application.Services.TrialMaintenanceService.AddTrialSites(System.Collections.Generic.List{IRaCIS.Core.Application.Contracts.DTO.TrialSiteCommand})">
|
||||
<summary>Setting页面 Site批量添加</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Services.TrialMaintenanceService.EditTrialSite(IRaCIS.Core.Application.Contracts.DTO.EditTrialSiteCommand)">
|
||||
<summary>
|
||||
项目site 编辑接口 New 可以设置为启用不启用 不启用 不会验证Code 重复
|
||||
</summary>
|
||||
<param name="editTrialSiteCommand"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Services.TrialMaintenanceService.EditTrialSite(System.Guid,System.Guid,System.String,System.String)">
|
||||
<summary>
|
||||
编辑项目中Site 基本信息
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace IRaCIS.Core.Application.Contracts.DTO
|
||||
{
|
||||
|
@ -9,10 +10,16 @@ namespace IRaCIS.Core.Application.Contracts.DTO
|
|||
public class SiteCrcQueryDTO : PageInput
|
||||
{
|
||||
public Guid TrialId { get; set; } = Guid.Empty;
|
||||
public string UserRealName { get; set; } = String.Empty;
|
||||
public string SiteName { get; set; } = String.Empty;
|
||||
public string TrialSiteAliasName { get; set; } = String.Empty;
|
||||
|
||||
public bool? IsDeleted { get; set; }
|
||||
|
||||
public string TrialSiteCode { get; set; } = String.Empty;
|
||||
|
||||
public string UserKeyInfo { get; set; } = String.Empty;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class TrialSiteCommand
|
||||
|
@ -22,9 +29,26 @@ namespace IRaCIS.Core.Application.Contracts.DTO
|
|||
|
||||
public string SiteName { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class AssginSiteCRCCommand
|
||||
public class EditTrialSiteCommand
|
||||
{
|
||||
//Guid id, Guid trialId, string trialSiteCode, string? trialSiteAliasName
|
||||
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string TrialSiteAliasName { get; set; } = String.Empty;
|
||||
|
||||
public string TrialSiteCode { get; set; } = String.Empty;
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AssginSiteCRCCommand
|
||||
{
|
||||
public Guid TrialId { get; set; }
|
||||
public Guid SiteId { get; set; }
|
||||
|
@ -34,7 +58,7 @@ public class AssginSiteCRCCommand
|
|||
|
||||
}
|
||||
|
||||
public class AssginSiteCRCListDTO:AssginSiteCRCCommand
|
||||
public class AssginSiteCRCListDTO : AssginSiteCRCCommand
|
||||
{
|
||||
public Guid UserTypeId { get; set; }
|
||||
public string UserType { get; set; } = String.Empty;
|
||||
|
@ -58,7 +82,7 @@ public class AssginSiteCRCCommand
|
|||
|
||||
public class TrialSiteScreeningDTO
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public string SiteName { get; set; } = String.Empty;
|
||||
public string SiteCode { get; set; } = String.Empty;
|
||||
public string City { get; set; } = String.Empty;
|
||||
|
@ -66,7 +90,7 @@ public class AssginSiteCRCCommand
|
|||
public Guid HospitalId { get; set; } = Guid.Empty;
|
||||
|
||||
|
||||
public string HospitalName { get; set; } = String.Empty;
|
||||
public string HospitalName { get; set; } = String.Empty;
|
||||
|
||||
public bool IsSelect { get; set; }
|
||||
}
|
||||
|
|
|
@ -105,6 +105,8 @@ namespace IRaCIS.Application.Contracts
|
|||
|
||||
public string TrialSiteCode { get; set; } = String.Empty;
|
||||
public string TrialSiteAliasName { get; set; } = String.Empty;
|
||||
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
public string Site { get; set; } = String.Empty;
|
||||
|
|
|
@ -62,34 +62,7 @@ namespace IRaCIS.Application.Services
|
|||
return await query.ToPagedListAsync(param.PageIndex,
|
||||
param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "UpdateTime" : param.SortField, param.Asc);
|
||||
|
||||
|
||||
//from userTrial in.Where(userTrialLambda)
|
||||
// join user in _userRepository.Where(userLambda) on userTrial.UserId equals user.Id
|
||||
// // 判断site下面的用户是否已经选择
|
||||
// join userId in _userTrialSiteRepository.Where(t => t.TrialId == param.TrialId && t.SiteId == param.SiteId).Select(t => t.UserId).Distinct() on user.Id equals userId into cc
|
||||
// from userId in cc.DefaultIfEmpty()
|
||||
// select new AssginSiteCRCListDTO()
|
||||
// {
|
||||
// //Id = userTrial.Id,
|
||||
// SiteId = param.SiteId,
|
||||
// UserId = userTrial.UserId,
|
||||
// UserRealName = user.LastName + " / " + user.FirstName,
|
||||
// UserName = user.UserName,
|
||||
|
||||
// TrialId = userTrial.TrialId,
|
||||
// UserTypeId = userTrial.UserTypeId,
|
||||
// UserTypeEnum= user.UserTypeEnum,
|
||||
|
||||
// //OrganizationTypeId = userTrial.OrganizationTypeId,
|
||||
// //OrganizationType = userTrial.OrganizationType,
|
||||
// //OrganizationId = userTrial.OrganizationId,
|
||||
// OrganizationName = user.OrganizationName,
|
||||
// UpdateTime = userTrial.UpdateTime,
|
||||
// UserType = userTrial.UserType,
|
||||
|
||||
// IsSelect = userId!=null,
|
||||
// };
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -114,34 +87,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
|
||||
//IQueryable<TrialUserScreeningDTO> userQueryable = from user in _userRepository.Where(userLambda)
|
||||
// join userType in _userTypeRoleRepository.AsQueryable() on user.UserTypeId equals userType.Id
|
||||
// //下面左连接 判断是否已经选择了
|
||||
// join userId in _userTrialRepository.Where(t => t.TrialId == trialUserQuery.TrialId).Select(t=>t.UserId).Distinct() on user.Id equals userId into cc
|
||||
// from userId in cc.DefaultIfEmpty()
|
||||
// select new TrialUserScreeningDTO()
|
||||
// {
|
||||
// TrialId = trialUserQuery.TrialId,
|
||||
// UserId = user.Id,
|
||||
// UserRealName = user.LastName + " / " + user.FirstName,
|
||||
// UserName = user.UserName,
|
||||
// Sex = user.Sex,
|
||||
|
||||
// Phone = user.Phone,
|
||||
// EMail = user.EMail,
|
||||
// UserTypeId = user.UserTypeId,
|
||||
|
||||
// OrganizationName = user.OrganizationName,
|
||||
// UserTypeEnum=user.UserTypeEnum,
|
||||
// //OrganizationTypeId = user.OrganizationTypeId,
|
||||
// //OrganizationType = user.OrganizationType,
|
||||
// //OrganizationId = user.OrganizationId,
|
||||
// DepartmentName = user.DepartmentName,
|
||||
// PositionName = user.PositionName,
|
||||
|
||||
// IsSelect = userId != null
|
||||
// UserType = userType.UserTypeShortName,
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -25,77 +25,16 @@ namespace IRaCIS.Core.Application.Services
|
|||
public async Task<PageOutput<SiteStatDTO>> GetSiteCRCList(SiteCrcQueryDTO param)
|
||||
{
|
||||
|
||||
var siteStatQuery = _trialSiteRepository.Where(t => t.TrialId == param.TrialId)
|
||||
var siteStatQuery = _trialSiteRepository.Where(t => t.TrialId == param.TrialId, ignoreQueryFilters: true)
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.SiteName), t => t.Site.SiteName.Contains(param.SiteName))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteAliasName), t => t.TrialSiteAliasName.Contains(param.TrialSiteAliasName))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteCode), t => t.TrialSiteAliasName.Contains(param.TrialSiteCode))
|
||||
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator, t => t.CRCUserList.Any(k => k.UserId == _userInfo.Id))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.UserRealName), t => t.CRCUserList.Any(k => (k.User.LastName + " / " + k.User.FirstName).Contains(param.UserRealName)))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.UserKeyInfo), t => t.CRCUserList.Any(k => (k.User.LastName + " / " + k.User.FirstName).Contains(param.UserKeyInfo)
|
||||
|| k.User.UserName.Contains(param.UserKeyInfo) || k.User.EMail.Contains(param.UserKeyInfo)))
|
||||
|
||||
.ProjectTo<SiteStatDTO>(_mapper.ConfigurationProvider);
|
||||
|
||||
#region 统计 废弃
|
||||
//= from trialSite in
|
||||
// join site in _siteRepository.Where() on trialSite.SiteId equals site.Id
|
||||
// join userTrialStat in _userTrialSiteRepository
|
||||
// .Where(t => t.TrialId == param.TrialId).GroupBy(u => u.SiteId)
|
||||
// .Select(g => new { SiteId = g.Key, UserCount = g.Count() }) on site.Id equals userTrialStat.SiteId into kk
|
||||
// from userTrialStat in kk.DefaultIfEmpty()
|
||||
|
||||
// join subjectStat in _subjectRepository.Where(t => t.TrialId == param.TrialId).GroupBy(u => u.SiteId)
|
||||
// .Select(g => new { SiteId = g.Key, SubjectCount = g.Count() }) on site.Id equals subjectStat
|
||||
// .SiteId
|
||||
// into ST
|
||||
// from subjectStatItem in ST.DefaultIfEmpty()
|
||||
|
||||
// ////加入 Visit统计 通过site下的受试者过滤visit 加入siteId 后修改 不用通过site下的用户过滤
|
||||
// //join subjectVisitStat in _subjectVisitRepository.Find(t=>t.TrialId==param.TrialId).GroupBy(t => t.SiteId).Select(g => new { SiteId = g.Key, VisitCount = g.Count() }) on site.Id equals subjectVisitStat.SiteId into SSV
|
||||
// //from subjectVisitStatItem in SSV.DefaultIfEmpty()
|
||||
|
||||
// //join subjectVisitStat2 in _subjectVisitRepository.Find(t => t.TrialId == param.TrialId&&t.VisitExecuted).GroupBy(t => t.SiteId).Select(g => new { SiteId = g.Key, VisitCount = g.Count() }) on site.Id equals subjectVisitStat2.SiteId into SSV2
|
||||
// //from subjectVisitStatItem2 in SSV2.DefaultIfEmpty()
|
||||
|
||||
// join studyStat in _studyRepository.Where(t => t.TrialId == param.TrialId /*&& t.Status != (int)StudyStatus.Abandon*/).GroupBy(u => u.SiteId).Select(g => new { SiteId = g.Key, StudyCount = g.Count() }) on site.Id equals studyStat.SiteId into STT
|
||||
// from studyStatItem in STT.DefaultIfEmpty()
|
||||
// select new SiteStatDTO()
|
||||
// {
|
||||
// SiteId = site.Id,
|
||||
// Site = site.SiteName,
|
||||
// City = site.City,
|
||||
// Country = site.Country,
|
||||
|
||||
// TrialSiteCode = trialSite.TrialSiteCode,
|
||||
|
||||
|
||||
// //VisitCount = subjectVisitStatItem2.VisitCount,
|
||||
// //PlanVisitCount = subjectVisitStatItem.VisitCount,
|
||||
|
||||
|
||||
// StudyCount = studyStatItem.StudyCount,
|
||||
// UserCount = userTrialStat.UserCount,
|
||||
// SubjectCount = subjectStatItem.SubjectCount,
|
||||
|
||||
// UserList = trialSite.CRCUserList.Select(t => new UserTrialDTO()
|
||||
// {
|
||||
// Id = t.Id,
|
||||
// SiteId = t.SiteId,
|
||||
|
||||
// UserId = t.UserId,
|
||||
// UserRealName = t.UserRealName,
|
||||
|
||||
// TrialId = t.TrialId,
|
||||
// UserTypeId = t.UserTypeId,
|
||||
// UserType = t.UserType,
|
||||
// //OrganizationTypeId = userTrial.OrganizationTypeId,
|
||||
// //OrganizationType = userTrial.OrganizationType,
|
||||
// //OrganizationId = userTrial.OrganizationId,
|
||||
// OrganizationName = t.User.OrganizationName,
|
||||
// UserName = t.User.UserName,
|
||||
// Phone = t.User.Phone,
|
||||
// UpdateTime = t.UpdateTime,
|
||||
// }).ToList()
|
||||
// };
|
||||
#endregion
|
||||
|
||||
|
||||
return await siteStatQuery.ToPagedListAsync(param.PageIndex,
|
||||
param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "SiteCode" : param.SortField, param.Asc);
|
||||
|
||||
|
@ -108,63 +47,16 @@ namespace IRaCIS.Core.Application.Services
|
|||
public async Task<PageOutput<SiteStatSimpleDTO>> GetSiteCRCSimpleList(SiteCrcQueryDTO param)
|
||||
{
|
||||
|
||||
var siteStatQuery = _trialSiteRepository.Where(t => t.TrialId == param.TrialId)
|
||||
var siteStatQuery = _trialSiteRepository.Where(t => t.TrialId == param.TrialId).IgnoreQueryFilters()
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.SiteName), t => t.Site.SiteName.Contains(param.SiteName))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteAliasName), t => t.TrialSiteAliasName.Contains(param.TrialSiteAliasName))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.TrialSiteCode), t => t.TrialSiteAliasName.Contains(param.TrialSiteCode))
|
||||
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator, t => t.CRCUserList.Any(k => k.UserId == _userInfo.Id))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.UserRealName), t => t.CRCUserList.Any(k => (k.User.LastName + " / " + k.User.FirstName).Contains(param.UserRealName)))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(param.UserKeyInfo), t => t.CRCUserList.Any(k => (k.User.LastName + " / " + k.User.FirstName).Contains(param.UserKeyInfo)
|
||||
|| k.User.UserName.Contains(param.UserKeyInfo) || k.User.EMail.Contains(param.UserKeyInfo)))
|
||||
|
||||
.ProjectTo<SiteStatSimpleDTO>(_mapper.ConfigurationProvider);
|
||||
|
||||
#region 废弃
|
||||
//IQueryable<SiteStatSimpleDTO> siteStatQuery = from trialSite in _trialSiteRepository.Where(t => t.TrialId == param.TrialId)
|
||||
// join site in _siteRepository.AsQueryable() on trialSite.SiteId equals site.Id
|
||||
// join hospital in _hospitalRepository.AsQueryable() on site.HospitalId equals hospital.Id
|
||||
// join userTrialStat in _userTrialSiteRepository
|
||||
// .Where(t => t.TrialId == param.TrialId).GroupBy(u => u.SiteId)
|
||||
// .Select(g => new { SiteId = g.Key, UserCount = g.Count() }) on site.Id equals userTrialStat.SiteId into kk
|
||||
// from userTrialStat in kk.DefaultIfEmpty()
|
||||
// select new SiteStatSimpleDTO()
|
||||
// {
|
||||
// Id = trialSite.Id,
|
||||
// SiteId = site.Id,
|
||||
// Site = site.SiteName,
|
||||
// SiteCode = site.SiteCode,
|
||||
// TrialSiteCode = trialSite.TrialSiteCode,
|
||||
// Hospital = hospital.HospitalName,
|
||||
// DirectorName = site.DirectorName,
|
||||
// DirectorPhone = site.DirectorPhone,
|
||||
// ContactName = site.ContactName,
|
||||
// ContactPhone = site.ContactPhone,
|
||||
// City = site.City,
|
||||
// Country = site.Country,
|
||||
// UpdateTime = trialSite.UpdateTime,
|
||||
// UserCount = userTrialStat.UserCount,
|
||||
|
||||
// UserList = trialSite.CRCUserList.Select(t => new UserTrialDTO()
|
||||
// {
|
||||
// Id = t.Id,
|
||||
// SiteId = t.SiteId,
|
||||
|
||||
// UserId = t.UserId,
|
||||
// UserRealName = t.UserRealName,
|
||||
|
||||
// TrialId = t.TrialId,
|
||||
// UserTypeId = t.UserTypeId,
|
||||
// UserType = t.UserType,
|
||||
// //OrganizationTypeId = userTrial.OrganizationTypeId,
|
||||
// //OrganizationType = userTrial.OrganizationType,
|
||||
// //OrganizationId = userTrial.OrganizationId,
|
||||
// OrganizationName = t.User.OrganizationName,
|
||||
// UserName = t.User.UserName,
|
||||
// Phone = t.User.Phone,
|
||||
// UpdateTime = t.UpdateTime,
|
||||
// }).ToList()
|
||||
// };
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
var result = await siteStatQuery.ToPagedListAsync(param.PageIndex,
|
||||
param.PageSize, string.IsNullOrWhiteSpace(param.SortField) ? "Site" : param.SortField, param.Asc);
|
||||
|
@ -175,12 +67,12 @@ namespace IRaCIS.Core.Application.Services
|
|||
|
||||
/// <summary>获取某一Site下面的负责的CRC列表</summary>
|
||||
[HttpGet, Route("{trialId:guid}/{siteId:guid}")]
|
||||
public async Task<List<UserTrialDTO>> GetTrialSiteCRCList(Guid trialId,Guid siteId)
|
||||
public async Task<List<UserTrialDTO>> GetTrialSiteCRCList(Guid trialId, Guid siteId)
|
||||
{
|
||||
var query = _repository.Where<TrialSiteUser>(t => t.TrialId == trialId && t.SiteId==siteId).IgnoreQueryFilters()
|
||||
var query = _repository.Where<TrialSiteUser>(t => t.TrialId == trialId && t.SiteId == siteId).IgnoreQueryFilters()
|
||||
.ProjectTo<UserTrialDTO>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await query.ToListAsync();
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
|
@ -220,21 +112,76 @@ namespace IRaCIS.Core.Application.Services
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 编辑项目中Site 基本信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="trialId"></param>
|
||||
/// <param name="trialSiteCode"></param>
|
||||
/// <param name="trialSiteAliasName"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 项目site 编辑接口 New 可以设置为启用不启用 不启用 不会验证Code 重复
|
||||
/// </summary>
|
||||
/// <param name="editTrialSiteCommand"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<IResponseOutput> EditTrialSite(EditTrialSiteCommand editTrialSiteCommand)
|
||||
{
|
||||
|
||||
var dbEntity = await _trialSiteRepository.FirstOrDefaultAsync(t => t.Id == editTrialSiteCommand.Id, true);
|
||||
|
||||
if (dbEntity == null) return Null404NotFound(dbEntity);
|
||||
|
||||
var trialId = dbEntity.TrialId;
|
||||
var siteId = dbEntity.SiteId;
|
||||
|
||||
if (editTrialSiteCommand.IsDeleted)
|
||||
{
|
||||
|
||||
//if (await _repository.AnyAsync<TrialSiteUser>(t => t.TrialId == trialId && t.SiteId == siteId))
|
||||
//{
|
||||
// return ResponseOutput.NotOk("The site has been associated with CRC, and couldn't be deleted.");
|
||||
//}
|
||||
|
||||
if (await _repository.AnyAsync<Subject>(t => t.SiteId == siteId && t.TrialId == trialId))
|
||||
{
|
||||
return ResponseOutput.NotOk("The subjects has been added to this site, and couldn't be deleted.");
|
||||
}
|
||||
|
||||
//if (await _repository.AnyAsync<DicomStudy>(t => t.SiteId == siteId && t.TrialId == trialId))
|
||||
//{
|
||||
// return ResponseOutput.NotOk("The site has been uploaded study, and couldn't be deleted.");
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (await _trialSiteRepository.AnyAsync(t => t.Id != editTrialSiteCommand.Id && t.TrialSiteCode == editTrialSiteCommand.TrialSiteCode && t.TrialId == editTrialSiteCommand.TrialId))
|
||||
{
|
||||
return ResponseOutput.NotOk("Code is not allowed to be repeated");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_mapper.Map(editTrialSiteCommand, dbEntity);
|
||||
|
||||
await _trialSiteRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 编辑项目中Site 基本信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="trialId"></param>
|
||||
/// <param name="trialSiteCode"></param>
|
||||
/// <param name="trialSiteAliasName"></param>
|
||||
/// <returns></returns>
|
||||
[UnitOfWork]
|
||||
[HttpPost("{trialId:guid}/{id:guid}/{trialSiteCode}/{trialSiteAliasName?}")]
|
||||
[TypeFilter(typeof(TrialResourceFilter))]
|
||||
[Obsolete]
|
||||
public async Task<IResponseOutput> EditTrialSite(Guid id, Guid trialId, string trialSiteCode, string? trialSiteAliasName)
|
||||
{
|
||||
|
||||
if (await _trialSiteRepository.AnyAsync(t => t.Id != id && t.TrialSiteCode == trialSiteCode && t.TrialId == trialId))
|
||||
if (await _trialSiteRepository.AnyAsync(t => t.Id != id && t.TrialSiteCode == trialSiteCode && t.TrialId == trialId && t.IsDeleted == false, true))
|
||||
{
|
||||
return ResponseOutput.NotOk("Code is not allowed to be repeated");
|
||||
}
|
||||
|
@ -250,6 +197,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
[HttpDelete("{id:guid}/{trialId:guid}")]
|
||||
[TrialAudit(AuditType.TrialAudit, AuditOptType.DeleteTrialSite)]
|
||||
[TypeFilter(typeof(TrialResourceFilter))]
|
||||
[Obsolete]
|
||||
public async Task<IResponseOutput> DeleteTrialSite(Guid id)
|
||||
{
|
||||
var relation = await _trialSiteRepository.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
@ -298,9 +246,9 @@ namespace IRaCIS.Core.Application.Services
|
|||
|
||||
//[TrialAudit(AuditType.TrialAudit, AuditOptType.DeleteTrialSiteCRC)]
|
||||
[TypeFilter(typeof(TrialResourceFilter))]
|
||||
public async Task<IResponseOutput> DeleteSiteCRC(Guid id, bool isDelete )
|
||||
public async Task<IResponseOutput> DeleteSiteCRC(Guid id, bool isDelete)
|
||||
{
|
||||
var isSuccess = await _repository.UpdateFromQueryAsync<TrialSiteUser>(u => u.Id == id,u=>new TrialSiteUser()
|
||||
var isSuccess = await _repository.UpdateFromQueryAsync<TrialSiteUser>(u => u.Id == id, u => new TrialSiteUser()
|
||||
{ IsDeleted = isDelete, RemoveTime = isDelete ? DateTime.Now : null });
|
||||
|
||||
return ResponseOutput.Result(isSuccess);
|
||||
|
|
|
@ -22,9 +22,10 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
EntityEntry Entry(TEntity t);
|
||||
|
||||
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> exp = null);
|
||||
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> exp);
|
||||
Task<int> CountAsync(Expression<Func<TEntity, bool>> whereLambda = null);
|
||||
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> exp = null, bool ignoreQueryFilters = false);
|
||||
|
||||
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> exp,bool ignoreQueryFilters=false);
|
||||
Task<int> CountAsync(Expression<Func<TEntity, bool>> whereLambda = null, bool ignoreQueryFilters = false);
|
||||
|
||||
ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
|
||||
Task<bool> AddRangeAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
public interface IQueryRepository<TEntity> : IQueryRepository<TEntity, Guid> where TEntity : Entity
|
||||
{
|
||||
TEntity ImageFind(Guid id, Type type);
|
||||
IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> exp = null, bool isTraking = false);
|
||||
IQueryable<TEntity> AsQueryable();
|
||||
IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> exp = null, bool isTraking = false, bool ignoreQueryFilters = false);
|
||||
IQueryable<TEntity> AsQueryable( bool ignoreQueryFilters = false);
|
||||
|
||||
IQueryable<TEntity> WhereIf(bool condition, Expression<Func<TEntity, bool>> filter);
|
||||
IQueryable<TDestination> ProjectTo<TDestination>(IConfigurationProvider configuration, params Expression<Func<TDestination, object>>[] membersToExpand);
|
||||
|
|
|
@ -113,10 +113,18 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
return await _dbContext.FindAsync<TEntity>(keyValues);
|
||||
}
|
||||
|
||||
public async Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> exp = null)
|
||||
public async Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> exp = null, bool ignoreQueryFilters = false)
|
||||
{
|
||||
if (exp == null) return await _dbSet.FirstOrDefaultAsync().ConfigureAwait(false);
|
||||
return await _dbSet.FirstOrDefaultAsync(exp).ConfigureAwait(false);
|
||||
|
||||
var query = _dbSet.AsQueryable();
|
||||
|
||||
if (ignoreQueryFilters)
|
||||
{
|
||||
query = query.IgnoreQueryFilters();
|
||||
}
|
||||
if (exp == null)
|
||||
return await query.FirstOrDefaultAsync().ConfigureAwait(false);
|
||||
return await query.FirstOrDefaultAsync(exp).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
|
||||
|
@ -205,14 +213,28 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<bool> AnyAsync(Expression<Func<TEntity, bool>> exp)
|
||||
public async Task<bool> AnyAsync(Expression<Func<TEntity, bool>> exp, bool ignoreQueryFilters = false)
|
||||
{
|
||||
return await _dbSet.AsNoTracking().AnyAsync(exp);
|
||||
var query = _dbSet.AsQueryable();
|
||||
|
||||
if (ignoreQueryFilters)
|
||||
{
|
||||
query = query.IgnoreQueryFilters();
|
||||
}
|
||||
|
||||
return await query.AsNoTracking().AnyAsync(exp);
|
||||
}
|
||||
|
||||
public async Task<int> CountAsync(Expression<Func<TEntity, bool>> whereLambda = null)
|
||||
public async Task<int> CountAsync(Expression<Func<TEntity, bool>> whereLambda = null, bool ignoreQueryFilters = false)
|
||||
{
|
||||
return whereLambda == null ? await _dbSet.AsNoTracking().CountAsync() : await _dbSet.AsNoTracking().CountAsync(whereLambda);
|
||||
var query = _dbSet.AsQueryable();
|
||||
|
||||
if (ignoreQueryFilters)
|
||||
{
|
||||
query = query.IgnoreQueryFilters();
|
||||
}
|
||||
|
||||
return whereLambda == null ? await query.AsNoTracking().CountAsync() : await query.AsNoTracking().CountAsync(whereLambda);
|
||||
}
|
||||
|
||||
// Z.EntityFramework.Plus.EFCore
|
||||
|
@ -251,9 +273,16 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
}
|
||||
|
||||
public IQueryable<TEntity> AsQueryable()
|
||||
public IQueryable<TEntity> AsQueryable( bool ignoreQueryFilters = false)
|
||||
{
|
||||
return _dbSet.AsNoTracking();
|
||||
var query = _dbSet.AsQueryable();
|
||||
|
||||
if (ignoreQueryFilters)
|
||||
{
|
||||
query = query.IgnoreQueryFilters();
|
||||
}
|
||||
|
||||
return query.AsNoTracking();
|
||||
}
|
||||
|
||||
public IQueryable<TResult> Select<TResult>(Expression<Func<TEntity, TResult>> selector)
|
||||
|
@ -266,7 +295,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
return condition ? _dbSet.AsNoTracking().Where(filter) : _dbSet.AsNoTracking();
|
||||
}
|
||||
|
||||
public IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> exp = null, bool isTraking = false)
|
||||
public IQueryable<TEntity> Where(Expression<Func<TEntity, bool>> exp = null, bool isTraking = false,bool ignoreQueryFilters = false)
|
||||
{
|
||||
IQueryable<TEntity> query = _dbSet;
|
||||
|
||||
|
@ -275,6 +304,11 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
query = query.AsNoTracking();
|
||||
}
|
||||
|
||||
if (ignoreQueryFilters)
|
||||
{
|
||||
query = query.IgnoreQueryFilters();
|
||||
}
|
||||
|
||||
if (exp != null)
|
||||
{
|
||||
query = query.Where(exp);
|
||||
|
|
Loading…
Reference in New Issue