public IActionResult Add([FromBody] machine_status_alert ec) { string msg = ""; string myurl1 = url + "api/v1/configuration/andon/machine_status_alert"; string result1 = GetUrl(myurl1); JObject jo1 = (JObject)JsonConvert.DeserializeObject(result1); var typeList = CommonHelper <machine_status_alert> .Get(myurl1, HttpContext); var list = typeList.Any(p => p.machine_id == ec.machine_id && p.machine_status == ec.machine_status); if (list == false)//没有重复的 { string myurl = url + "api/v1/configuration/andon/machine_status_alert"; var postData = JsonConvert.SerializeObject(ec); string result = PostUrl(myurl, postData); JObject jo = (JObject)JsonConvert.DeserializeObject(result); switch (Convert.ToInt32(jo["code"])) { case 200: msg = "Success"; break; case 400: msg = "fail"; break; } } return(Json(msg)); }
public IActionResult Delete([FromBody] machine_status_alert ec) { string myurl = url + "api/v1/configuration/andon/machine_status_alert?id=" + ec.id.ToString(); string result = DeleteUrl(myurl); JObject jo = (JObject)JsonConvert.DeserializeObject(result); switch (Convert.ToInt32(jo["code"])) { case 200: Json("Success"); break; case 400: break; case 410: break; case 411: break; default: break; } return(Json("Success")); }