Exemplo n.º 1
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 = "添加失败,系统已有该节点",
                })));
            }
        }