public JsonResult AddGateWay([System.Web.Http.FromBody] iot_gateway model) { if (util.IsExist(0, model.MAC)) { return(Json(new { status = StatusCode.FAIL, meassage = "网关MAC地址已被使用" })); } //网关的基本信息 iot_gateway gatway = new iot_gateway { MAC = model.MAC, Name = model.Name, CreateTime = new DateTime(), EditTIme = null }; db.iot_gateway.Add(gatway); var taskinfo = new { status = StatusCode.SUCCESS, message = "添加成功" }; int uprows = db.SaveChanges(); if (uprows < 1) { taskinfo = new { status = StatusCode.FAIL, message = "添加失败" }; } return(Json(taskinfo, JsonRequestBehavior.AllowGet)); }