Exemple #1
0
 public IActionResult GetCountriesInAContinent(string continentName = null, string continentCodeId = null, int?geonameId = null,
                                               int?pageNumber       = null, int?pageSize = null)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(continentName) || !string.IsNullOrWhiteSpace(continentCodeId) || geonameId > 0)
         {
             if (((pageNumber != null && pageSize != null) && (pageNumber > 0 && pageSize > 0)) || (pageSize == null && pageNumber == null))
             {
                 try
                 {
                     IEnumerable <Country> result = repository.GetCountriesInAContinent(continentName, continentCodeId, geonameId, pageNumber, pageSize);
                     if (result != null && result.Count() > 0)
                     {
                         return(Ok(result));
                     }
                     else
                     {
                         return(NotFound());
                     }
                 }
                 catch (Exception ex)
                 {
                     //Debug.WriteLine(ex);
                     throw;
                 }
             }
             else
             {
                 return(BadRequest("Both pageSize and pageNumber properties need to have valid values."));
             }
         }
         else
         {
             return(BadRequest("Please provide valid value of a continent code or continent name or geoname id."));
         }
     }
     catch (Exception ex)
     {
         //Debug.WriteLine(ex);
         throw;
     }
 }