Example #1
0
        public async Task <ActionResult <IList <TrailerDTO> > > GetAll()
        {
            try
            {
                var results = await _trailerRepository.GetAllTrailers();

                var mappedResults  = _mapper.Map <IList <TrailerDTO> >(results);
                var hateoasResults = mappedResults.Select(t => HateoasMainLinks(t));

                if (mappedResults.IsNullOrEmpty())
                {
                    return(NotFound());
                }

                return(Ok(hateoasResults));
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database failure: {e.Message}"));
            }
        }