public async Task <IActionResult> Get([FromQuery] string search = null) { if (await _clinicRepository.GetDoctorsAsync() is IEnumerable <Doctor> doctors) { //if search isn't null, filter list of all doctors by name if (search is not null) { var searchDoctor = doctors.FirstOrDefault(d => d.Name.ToLower() == search.ToLower()); return(Ok(searchDoctor)); } else { return(Ok(doctors)); } } else { return(NotFound()); } }