public async Task <ActionResult <IList <DirectorDTO> > > GetByName([FromQuery] string name) { try { var results = await _directorRepository.GetDirectorsByName(name); IEnumerable <DirectorDTO> mappedResults = _mapper.Map <IList <DirectorDTO> >(results); IEnumerable <DirectorDTO> hateoasResults = mappedResults.Select(m => HateoasMainLinks(m)); if (mappedResults.IsNullOrEmpty()) { return(NotFound()); } else { return(Ok(hateoasResults)); } } catch (Exception exception) { return(StatusCode(StatusCodes.Status500InternalServerError, $"Database failure: {exception.Message}")); } }