public Response SetNewPost(PostParam post) { var result = RunInsertJson(post.images); if (result.valid) { var procedure = "sp_post_set"; using (var conn = new MySqlConnection(_connectionString)) { try { conn.Open(); var param = new DynamicParameters(); param.Add("INname", post.name); param.Add("INcontent", post.content); param.Add("INurl", post.url); var data = conn.QueryFirstOrDefault <Response>(procedure, param, commandType: System.Data.CommandType.StoredProcedure); return(data); } catch (Exception ex) { throw; } } } else { return(null); } }
public void AddPostParams(string strKey, string strValue) { PostParam data = new PostParam(); data.strPostKey = strKey; data.strPostValue = strValue; m_listParams.Add(data); }
public IActionResult SetPost([FromBody] PostParam post) { if (!Request.Headers.ContainsKey("Authorization")) { return(Unauthorized()); } var data = _alphahomeService.SetNewPost(post); if (data.valid) { return(new JsonResult(data)); } return(BadRequest(data)); }
public void doPost(PostParam parameter) { try { Uri uri = new Uri(this.PostUri); WebRequest webRequest = WebRequest.Create(uri); webRequest.Headers.Add(HttpRequestHeader.AcceptLanguage, this.Language); if (this.Proxy != null) { webRequest.Proxy = Proxy; } webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded"; string parameterString = ""; parameterString += parameter.Paramter + "=" + parameter.Value + "&"; parameterString = parameterString.Substring(0, parameterString.Length - 1); byte[] byteArray = Encoding.UTF8.GetBytes(parameterString); webRequest.ContentLength = byteArray.Length; Stream stream = webRequest.GetRequestStream(); stream.Write(byteArray, 0, byteArray.Length); stream.Close(); WebResponse webResponse = webRequest.GetResponse(); stream = webResponse.GetResponseStream(); StreamReader streamReader = new StreamReader(stream); string responseStream = streamReader.ReadToEnd(); webResponse.Close(); streamReader.Close(); if (PostComplete != null) { PostComplete.Invoke(responseStream, null); } } catch (Exception exception) { throw exception; } }
// POST api/values public List <HeatMapData> Post([FromBody] PostParam postParam) { if (postParam == null || postParam.visibleRegion == null || postParam.visibleRegion.latLngBounds == null) { return(new List <HeatMapData>()); } var bounds = postParam.visibleRegion.latLngBounds; var points = Gis.DefaultInstance.HeatMapData .Where( // visibleRegionの中に入るHeatMapData抽出 m => bounds.southwest.latitude <= m.Latitude && m.Latitude <= bounds.northeast.latitude && bounds.southwest.longitude <= m.Longitude && m.Longitude <= bounds.northeast.longitude); if (postParam.maxPoint != null && postParam.maxPoint < points.Count()) { points = points.OrderByDescending(m => m.Intensity).Take(postParam.maxPoint.Value); } return(points.ToList()); }
public void TestMethod1() { // var baseUrl = "http://trafficmap.azurewebsites.net/api/values/"; var baseUrl = "http://localhost:65359/api/values"; var postParam = new PostParam() { visibleRegion = new VisibleRegion() { latLngBounds = new LatLngBounds() { northeast = new LatLng() { latitude = 35.2446699, longitude = 139.6905788 }, southwest = new LatLng() { latitude = 35.2242776, longitude = 139.6676699 } } }, maxPoint = 100, }; var data = new List <HeatMapData>(); using (var client = new HttpClient()) { var response = client.PostAsJsonAsync(baseUrl, postParam).Result; if (response.IsSuccessStatusCode) { var content = response.Content.ReadAsStringAsync().Result; data = new JavaScriptSerializer().Deserialize <List <HeatMapData> >(content); } } }
public Response SetNewPost(PostParam post) { return _alphahomeRepo.SetNewPost(post); }