修改仓储

This commit is contained in:
he
2022-04-01 16:48:35 +08:00
parent 31f90660d3
commit aa18ce52f2
17 changed files with 89 additions and 82 deletions
@@ -9,9 +9,12 @@ namespace IRaCIS.Application.Services
public class CroService : BaseService, ICroService
{
private readonly IRepository<CRO> _croRepository;
public CroService(IRepository<CRO> croRepository)
private readonly IRepository<Trial> _trialRepository;
public CroService(IRepository<CRO> croRepository, IRepository<Trial> trialRepository)
{
_croRepository = croRepository;
this._trialRepository = trialRepository;
}
/// <summary> 分页获取CRO列表 </summary>
@@ -59,7 +62,7 @@ namespace IRaCIS.Application.Services
[HttpDelete("{croCompanyId:guid}")]
public async Task<IResponseOutput> DeleteCro(Guid cROCompanyId)
{
if (await _repository.GetQueryable<Trial>().AnyAsync(t => t.CROId == cROCompanyId))
if (await _trialRepository.AnyAsync(t => t.CROId == cROCompanyId))
{
return ResponseOutput.NotOk("This CRO has participated in the trial and couldn't be deleted.");
}
@@ -9,10 +9,12 @@ namespace IRaCIS.Application.Services
public class HospitalService : BaseService, IHospitalService
{
private readonly IRepository<Hospital> _hospitalRepository;
private readonly IRepository<Doctor> _doctorRepository;
public HospitalService(IRepository<Hospital> hospitalRepository)
public HospitalService(IRepository<Hospital> hospitalRepository, IRepository<Doctor> doctorRepository)
{
_hospitalRepository = hospitalRepository;
this._doctorRepository = doctorRepository;
}
/// <summary> 获取所有医院列表 </summary>
@@ -43,7 +45,7 @@ namespace IRaCIS.Application.Services
[HttpDelete("{hospitalId:guid}")]
public async Task<IResponseOutput> DeleteHospital(Guid hospitalId)
{
if (await _repository.GetQueryable<Doctor>().AnyAsync(t => t.Id == hospitalId))
if (await _doctorRepository.AnyAsync(t => t.Id == hospitalId))
{
return ResponseOutput.NotOk("There are already doctors registered in this hospital,and it couldn't be deleted");
}
@@ -9,10 +9,12 @@ namespace IRaCIS.Application.Services
public class SiteService : BaseService, ISiteService
{
private readonly IRepository<Site> _siteRepository;
private readonly IRepository<TrialSiteUser> _trialSiteUserRepository;
public SiteService(IRepository<Site> siteRepository)
public SiteService(IRepository<Site> siteRepository, IRepository<TrialSiteUser> trialSiteUserRepository)
{
_siteRepository = siteRepository;
this._trialSiteUserRepository = trialSiteUserRepository;
}
/// <summary> 分页获取研究中心列表 </summary>
@@ -62,7 +64,7 @@ namespace IRaCIS.Application.Services
public async Task<IResponseOutput> DeleteSite(Guid siteId)
{
if (_repository.GetQueryable<TrialSiteUser>().Any(t => t.SiteId == siteId))
if (await _trialSiteUserRepository.AnyAsync(t => t.SiteId == siteId))
{
return ResponseOutput.NotOk("This site has participated in the trial and couldn't be deleted.");
}
@@ -9,10 +9,12 @@ namespace IRaCIS.Application.Services
public class SponsorService : BaseService, ISponsorService
{
private readonly IRepository<Sponsor> _sponsorRepository;
private readonly IRepository<Trial> _trialRepository;
public SponsorService(IRepository<Sponsor> sponsorRepository)
public SponsorService(IRepository<Sponsor> sponsorRepository, IRepository<Trial> trialRepository)
{
_sponsorRepository = sponsorRepository;
this._trialRepository = trialRepository;
}
/// <summary> 分页获取申办方列表 </summary>
@@ -63,7 +65,7 @@ namespace IRaCIS.Application.Services
public async Task<IResponseOutput> DeleteSponsor(Guid sponsorId)
{
if (await _repository.GetQueryable<Trial>().AnyAsync(t => t.CROId == sponsorId))
if (await _trialRepository.AnyAsync(t => t.CROId == sponsorId))
{
return ResponseOutput.NotOk("This sponsor has participated in the trial and couldn't be deleted.");
}