Ejemplo n.º 1
0
        public IActionResult GetCounties(int stateId)
        {
            try
            {
                if (!_myAppRepository.StateExists(stateId))
                {
                    _logger.LogInformation($"State with Fips {stateId} wasn't found when " +
                                           $"accessing Counties");
                    return(NotFound());
                }

                var countiesForState = _myAppRepository.GetCountiesForState(stateId);

                return(Ok(_mapper.Map <IEnumerable <CountyDto> >(countiesForState)));
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"Exception while getting points of interest while state with and a Fips code of {stateId}", ex);
                return(StatusCode(500, "A problem happened while handling this request."));
            }
        }