Exemplo n.º 1
0
        public async Task <ActionResult <CountryDto[]> > GetCountries(
            [FromQuery] bool includeCities             = false,
            [FromQuery] bool includeTravelRestrictions = false,
            [FromQuery] bool includeAttractions        = false,
            [FromQuery] int attractionsMinRating       = 0,
            [FromQuery] int attractionsMaxRating       = 5)
        {
            try
            {
                var results = await _countryRepo.GetCountries
                              (
                    includeCities,
                    includeTravelRestrictions,
                    includeAttractions,
                    attractionsMinRating,
                    attractionsMaxRating
                              );

                return(Ok(results));
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }
        }
        public async Task <ActionResult <CountryDto[]> > GetCountries(
            [FromQuery] bool includeCities             = false,
            [FromQuery] bool includeTravelRestrictions = false,
            [FromQuery] bool isRightHandTraffic        = false,
            [FromQuery] bool isLeftHandTraffic         = false,
            [FromQuery] string language = "")
        {
            try
            {
                var countries = await _countryRepo.GetCountries(includeCities, includeTravelRestrictions, isRightHandTraffic, isLeftHandTraffic, language);

                var mappedCountries = _mapper.Map <CountryDto[]>(countries);

                for (var i = 0; i < mappedCountries.Count(); i++)
                {
                    var countryLinks    = CreateLinksForCountries(mappedCountries[i].CountryId);
                    var attractionLinks = CreateLinksForCountryAttractions(countries[i]);

                    mappedCountries[i].Add(countryLinks, attractionLinks);
                }

                return(Ok(mappedCountries));
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }
        }
Exemplo n.º 3
0
 public ActionResult GetCountries()
 {
     return Json(_countryRepo.GetCountries().Select(x => new
     {
         countryID = x.Id,
         countryName = x.Country_name
     }).ToList(), JsonRequestBehavior.AllowGet);
 }
 // GET: api/Countries
 public IQueryable <CountryDTO> GetCountries()
 {
     return(_countryRepo.GetCountries().Select(country => new CountryDTO {
         Id = country.Id, Name = country.Name
     }));
 }
Exemplo n.º 5
0
 public IQueryable <CountryModel> GetCountries()
 {
     return(_ICountryRepo.GetCountries());
 }
 public IEnumerable <Country> Get()
 {
     return(repo.GetCountries());
 }