// 修改节点信息
        public void update(equipment_information lig)
        {
            //先查询要获取的对象
            var db_user = from a in agriculture.equipment_information where a.MAC == lig.MAC select a;

            db_user.FirstOrDefault().X = lig.X;
            db_user.FirstOrDefault().Y = lig.Y;

            agriculture.Entry <equipment_information>(db_user.FirstOrDefault()).State = System.Data.Entity.EntityState.Modified;
            agriculture.SaveChanges();
        }
Beispiel #2
0
        // 修改节点配置信息
        public ActionResult Update(equipment_information node)
        {
            ADevice device = new ADevice();

            device.update(node);
            return(Content(JsonConvert.SerializeObject(new
            {
                code = 1,
                des = "修改成功"
            })));
        }
Beispiel #3
0
        // 添加节点配置信息
        public ActionResult Add(equipment_information node)
        {
            ADevice device = new ADevice();
            var     rs     = device.select(node.MAC);

            // 本来没有该节点
            if (rs == null)
            {
                device.insert(node);
                if (device.select(node.MAC) != null)
                {
                    return(Content(JsonConvert.SerializeObject(new
                    {
                        code = 1,
                        des = "添加成功",
                    })));
                }
                else
                {
                    return(Content(JsonConvert.SerializeObject(new
                    {
                        code = 0,
                        des = "添加失败,未添加到数据库"
                    })));
                }
            }
            else
            // 本来有该节点
            {
                return(Content(JsonConvert.SerializeObject(new
                {
                    code = -1,
                    des = "添加失败,系统已有该节点",
                })));
            }
        }
 // 增加节点
 public void insert(equipment_information user)
 {
     agriculture.equipment_information.Add(user);
     agriculture.SaveChanges();
 }