Esempio n. 1
0
        public async Task <ActionResult <CityDto> > GetCityById(int id, [FromQuery] bool includeCountries = false)
        {
            try
            {
                var city = await _cityRepo.GetCityById(id, includeCountries);

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

                var mappedCity = _mapper.Map <CityDto>(city);

                var cityLinks       = CreateLinksForCity(mappedCity.CityId);
                var attractionLinks = CreateLinksForCityAttractions(city);

                mappedCity.Add(cityLinks, attractionLinks);

                return(Ok(mappedCity));
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }
        }
Esempio n. 2
0
 public CityModel GetCityById(Guid CityId)
 {
     return(_ICityRepo.GetCityById(CityId));
 }