public async Task <ActionResult <IList <DirectorDTO> > > GetAll()
        {
            try
            {
                var results = await _directorRepository.GetAllDirectors();

                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}"));
            }
        }
Пример #2
0
        public IEnumerable <Director> GetAllDirectors()
        {
            var result = _directorRepository.GetAllDirectors();

            return(result);
        }