Ejemplo n.º 1
0
        public async Task <ActionResult <CityDto> > GetCityByName(string name, bool includeCountries = false)
        {
            try
            {
                var result = await _cityRepo.GetCityByName(name, includeCountries);

                if (result == null)
                {
                    return(NotFound($"Couldn't find any cities with name: {name}"));
                }

                var mappedResult = _mapper.Map <CityDto>(result);

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