public async Task <List <DiseaseSearchResultDto> > SearchDiseasesForSymptomsAsync(FilterSymptomDto filter) { var syndromes = await _dbContext .Syndromes .Include(s => s.Disease) .Include(s => s.Symptoms) .Where(s => s.Symptoms.Any(sm => filter.SymptomIds.Contains(sm.Id))) .ToListAsync(); return(syndromes .Where(s => filter.SymptomIds.All(fi => s.Symptoms.Select(s => s.Id).Contains(fi))) .GroupBy(s => s.Disease) .Select(s => new DiseaseSearchResultDto { Name = s.Key.Name, Syndromes = _mapper.Map <List <SyndromeDto> >(s), Description = s.Key.Description, Id = s.Key.Id, SyndromeCount = s.Count() }) .ToList()); }
public Task <List <DiseaseSearchResultDto> > SearchDiseasesForSymptoms([FromQuery] FilterSymptomDto filter) => _diseaseService.SearchDiseasesForSymptomsAsync(filter);