public IHttpActionResult GetNode(string id) { nodeDAO = new NodeDAO(); nodeDetailDAO = new NodeDetailDAO(); NodeInfo node = new NodeInfo(); if (!nodeDAO.isNodeExist(id)) return NotFound(); NodeDetail nodeDetail = nodeDetailDAO.GetDetailByNodeId(id); if (null == nodeDetail) return NotFound(); node.NodeId = nodeDetail.NodeId; node.Humidity = nodeDetail.Humidity.Value; node.Raining = nodeDetail.Raining.Value; node.SoilMoisture = nodeDetail.SoilMoisture.Value; node.Temperature = nodeDetail.Temperature.Value; node.UpdateTime = nodeDetail.updateTime; node.NodeLocation = nodeDAO.FindNodeById(id).NodeLocation; if (node == null) { return NotFound(); } return Ok(node); }
public NodeInfo GetNodeInfo(String id) { NodeDAO nodeDAO = new NodeDAO(); NodeDetailDAO nodeDetailDAO = new NodeDetailDAO(); NodeInfo node = new NodeInfo(); if (!nodeDAO.isNodeExist(id)) { return(null); } NodeDetail nodeDetail = nodeDetailDAO.GetDetailByNodeId(id); if (null == nodeDetail) { return(null); } node.NodeId = nodeDetail.NodeId; node.Humidity = nodeDetail.Humidity.Value; node.Raining = nodeDetail.Raining.Value; node.SoilMoisture = nodeDetail.SoilMoisture.Value; node.Temperature = nodeDetail.Temperature.Value; node.UpdateTime = nodeDetail.updateTime; node.NodeLocation = nodeDAO.FindNodeById(id).NodeLocation; return(node); }