Example #1
0
        public async Task <ActionResult <IList <ActorDTO> > > GetByCountry([FromQuery] string country)
        {
            try
            {
                var result = await _actorRepository.GetActorsByCountry(country);

                var mappedResults = _mapper.Map <IList <ActorDTO> >(result).Select(a => HateoasMainLinks(a));

                if (result.Count == 0)
                {
                    return(NotFound(result));
                }
                return(Ok(mappedResults));
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database failure: {e.Message}"));
            }
        }