diff --git a/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs b/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs index 2700f5141..fb05d4d47 100644 --- a/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs +++ b/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs @@ -47,6 +47,13 @@ namespace IRaCIS.Application.Contracts } + public class TrialSiteInQuery:PageInput + { + public string? TrialSiteName { get; set; } + + public string? TrialCode { get; set; } + } + public class TrialSiteAddView { public Guid TrialSiteId { get; set; } diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index 32df16d12..33ccf3180 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -50,16 +50,21 @@ namespace IRaCIS.Application.Services return await _siteRepository.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); } - - public async Task> GetTrialSiteList() + [HttpPost] + public async Task> GetTrialSiteList(TrialSiteInQuery inQuery) { - return _repository.Where(t => t.SiteId == null).Select(t => new TrialSiteAddView() - { - TrialCode = t.Trial.TrialCode, - TrialSiteAliasName = t.TrialSiteAliasName, - TrialSiteId = t.Id, - TrialSiteName = t.TrialSiteName - }).ToList(); + var query = _repository.Where(t => t.SiteId == null) + .WhereIf(string.IsNullOrEmpty(inQuery.TrialSiteName), t => t.TrialSiteName.Contains(inQuery.TrialSiteName) || t.TrialSiteAliasName.Contains(inQuery.TrialSiteName)) + .WhereIf(string.IsNullOrEmpty(inQuery.TrialCode), t => t.Trial.TrialCode.Contains(inQuery.TrialCode)) + .Select(t => new TrialSiteAddView() + { + TrialCode = t.Trial.TrialCode, + TrialSiteAliasName = t.TrialSiteAliasName, + TrialSiteId = t.Id, + TrialSiteName = t.TrialSiteName + }); + + return await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(TrialSiteAddView.TrialCode) : inQuery.SortField, inQuery.Asc); } /// 添加研究中心