public async Task <IActionResult> GetAsync([FromQuery] string search = null) { List <Transfer_Specialty> SpecialtyAll; if (search == null) { _logger.LogInformation($"Retrieving all specialties"); SpecialtyAll = (await _specialtyRepository.GetSpecialtyAsync()).Select(Mapper.MapSpecialty).ToList(); } else { _logger.LogInformation($"Retrieving specialties with parameters {search}."); SpecialtyAll = (await _specialtyRepository.GetSpecialtyAsync(search)).Select(Mapper.MapSpecialty).ToList(); } try { _logger.LogInformation($"Sending {SpecialtyAll.Count} Specialties."); return(Ok(SpecialtyAll)); } catch (Exception e) { _logger.LogWarning($"Error! {e.Message}."); return(StatusCode(500)); } }