public HttpResponseMessage Map([FromUri] string format = "JSON", [FromUri] string type = "1") { try { if (!User.Identity.IsAuthenticated) { return(this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception("API key not specified."))); } if (Guid.Parse(ConfigurationManager.AppSettings["GeckoAPIkey"]).ToString() != User.Identity.Name) { return(this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception(string.Format("Unknown API key, should be '{0}'.", ConfigurationManager.AppSettings["GeckoAPIkey"])))); } //if (int.Parse(type) != 1) { return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException(string.Format("Type parameter '{0}' is wrong.", type))); } // You would modify what gets returned here to make it meaningful var retVal = new GeckoMapPoints() { Points = new List <MapPoint>() { new MapPoint() { City = new MapCity() { CityName = "london", CountryCode = "GB" }, Size = 10, Color = "d8f709" }, new MapPoint() { City = new MapCity() { CityName = "San Francisco", CountryCode = "US", RegionCode = "CA" } }, new MapPoint() { Latitude = "51.526263", Longitude = "-0.092429" }, new MapPoint() { Host = "geckoboard.com" }, new MapPoint() { IP = "72.38.123.170" } } }; return(this.Request.CreateResponse <GeckoMapPoints>(HttpStatusCode.OK, retVal)); } catch (Exception ex) { return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public HttpResponseMessage Map([FromUri]string format = "JSON", [FromUri]string type = "1") { try { if (!User.Identity.IsAuthenticated) { return this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception("API key not specified.")); } if (Guid.Parse(ConfigurationManager.AppSettings["GeckoAPIkey"]).ToString() != User.Identity.Name) { return this.Request.CreateErrorResponse(HttpStatusCode.Unauthorized, new Exception(string.Format("Unknown API key, should be '{0}'.", ConfigurationManager.AppSettings["GeckoAPIkey"]))); } //if (int.Parse(type) != 1) { return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ArgumentException(string.Format("Type parameter '{0}' is wrong.", type))); } // You would modify what gets returned here to make it meaningful var retVal = new GeckoMapPoints() { Points = new List<MapPoint>() { new MapPoint() { City = new MapCity() { CityName = "london", CountryCode = "GB" }, Size=10, Color="d8f709" }, new MapPoint() { City = new MapCity() { CityName = "San Francisco", CountryCode="US", RegionCode = "CA" } }, new MapPoint() { Latitude = "51.526263", Longitude = "-0.092429" }, new MapPoint() { Host = "geckoboard.com" }, new MapPoint() { IP = "72.38.123.170" } } }; return this.Request.CreateResponse<GeckoMapPoints>(HttpStatusCode.OK, retVal); } catch (Exception ex) { return this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex); } }