예제 #1
0
 public HttpResponseMessage Get([FromUri] Models.Location location)
 {
     if (!string.IsNullOrEmpty(location.ToString()))
     {
         try
         {
             var places = client.SearchPlaces(location, HttpContext.Current.Session["AccessToken"] as string);
             return(Request.CreateResponse <List <FPlace> >(HttpStatusCode.OK, places, "application/json"));
         }
         catch (InvalidOperationException ioEx)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, ioEx.Message));
         }
         catch (ArgumentNullException anEx)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, "Bad location data"));
         }
         catch (Exception ex)
         {
             return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
         }
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.NotFound, "Empty location"));
     }
 }
예제 #2
0
 public void SearchPlaces_WhenLocationNull_ShouldThrowArgumentNullException()
 {
     client.SearchPlaces(null, null);
 }