68 lines
2.7 KiB
C#
68 lines
2.7 KiB
C#
using AutoMapper;
|
|
using AutoMapper.QueryableExtensions;
|
|
using IRaCIS.Application.Interfaces;
|
|
using IRaCIS.Application.ViewModels;
|
|
using IRaCIS.Core.Domain.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace IRaCIS.Application.Services
|
|
{
|
|
public class InstitutionService: IInstitutionService
|
|
{
|
|
private readonly IDictionaryRepository _dictionaryRepository;
|
|
private readonly ICRORepository _croRepository;
|
|
private readonly ISponsorRepository _sponsorRepository;
|
|
private readonly IHospitalRepository _hospitalRepository;
|
|
private readonly ISiteRepository _siteRepository;
|
|
private readonly IMapper _mapper;
|
|
|
|
public InstitutionService(IDictionaryRepository dictionaryRepository,
|
|
ICRORepository crOCompanyRepository,
|
|
ISponsorRepository sponsorRepository,
|
|
IHospitalRepository hospitalRepository,
|
|
ISiteRepository researchCenterRepository,IMapper mapper)
|
|
{
|
|
_dictionaryRepository = dictionaryRepository;
|
|
_croRepository = crOCompanyRepository;
|
|
_sponsorRepository = sponsorRepository;
|
|
_hospitalRepository = hospitalRepository;
|
|
_siteRepository = researchCenterRepository;
|
|
_mapper = mapper;
|
|
}
|
|
public IEnumerable<InstitutionDTO> GetInstitutionSelectionByTypeId(Guid typeId)
|
|
{
|
|
List<InstitutionDTO> result = new List<InstitutionDTO>();
|
|
//bool isSuccess = false;
|
|
|
|
if (typeId != Guid.Empty)
|
|
{
|
|
var dicItem = _dictionaryRepository.FindSingleOrDefault(u => u.Id == typeId);
|
|
|
|
if (dicItem.Type.Contains("CRO"))
|
|
{
|
|
result.AddRange(_croRepository.GetAll().ProjectTo<InstitutionDTO>(_mapper.ConfigurationProvider));
|
|
//isSuccess = true;
|
|
}
|
|
if (dicItem.Type.Contains("Sponsor"))
|
|
{
|
|
result.AddRange(_sponsorRepository.GetAll().ProjectTo<InstitutionDTO>(_mapper.ConfigurationProvider));
|
|
//isSuccess = true;
|
|
}
|
|
if (dicItem.Type.Contains("Hospital"))
|
|
{
|
|
result.AddRange(_hospitalRepository.GetAll().ProjectTo<InstitutionDTO>(_mapper.ConfigurationProvider));
|
|
//isSuccess = true;
|
|
}
|
|
if (dicItem.Type.Contains("Site"))
|
|
{
|
|
result.AddRange(_siteRepository.GetAll().ProjectTo<InstitutionDTO>(_mapper.ConfigurationProvider));
|
|
//isSuccess = true;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|