コード例 #1
0
        // GET api/powerinfo/5
        public List<PowerInfo> Get(string id) {

            List<PowerInfo> powerinfos = new List<PowerInfo>();

            SensorConditionEntities db = new SensorConditionEntities();
            foreach (var row in db.PowerSensors) {
                PowerInfo powerinfo = new PowerInfo();
                powerinfo.SensorID = row.SensorID.ToString();
                if (id.Equals("ConsumerElectronics")) {
                    powerinfo.ConsumerElectronics = row.ConsumerElectronics;
                } else if (id.Equals("Type")) {
                    powerinfo.Type = row.Type;
                } else if (id.Equals("LatestUploadDate")) {
                    powerinfo.LatestUploadDate = row.LatestUploadDate;
                } else if (id.Equals("BaseStationName")) {
                    powerinfo.BaseStationName = row.BaseStationName;
                } else if (id.Equals("UploadCycle")) {
                    powerinfo.UploadCycle = row.UploadCycle;
                } else if (id.Equals("Detail")) {
                    powerinfo.Detail = row.Detail;
                } else if (id.Equals("All")) {
                    powerinfo.ConsumerElectronics = row.ConsumerElectronics;
                    powerinfo.Type = row.Type;
                    powerinfo.LatestUploadDate = row.LatestUploadDate;
                    powerinfo.BaseStationName = row.BaseStationName;
                    powerinfo.UploadCycle = row.UploadCycle;
                    powerinfo.Detail = row.Detail;
                }
                powerinfos.Add(powerinfo);
            }


            return powerinfos;
        }
コード例 #2
0
        // GET api/doorinfo/5
        public List<DoorInfo> Get(string id) {

            List<DoorInfo> doorinfos = new List<DoorInfo>();

            SensorConditionEntities db = new SensorConditionEntities();
            foreach (var row in db.DoorSensors) {
                DoorInfo doorinfo = new DoorInfo();
                doorinfo.SensorID = row.SensorID.ToString();
                if (id.Equals("Door")) {
                    doorinfo.Door = row.Door;
                } else if (id.Equals("BatteryExchangeDate")) {
                    doorinfo.BatteryExchangeDate = row.BatteryExchangeDate;
                } else if (id.Equals("LatestUploadDate")) {
                    doorinfo.LatestUploadDate = row.LatestUploadDate;
                } else if (id.Equals("BaseStationName")) {
                    doorinfo.BaseStationName = row.BaseStationName;
                } else if (id.Equals("Detail")) {
                    doorinfo.Detail = row.Detail;
                } else if (id.Equals("All")) {
                    doorinfo.Door = row.Door;
                    doorinfo.BatteryExchangeDate = row.BatteryExchangeDate;
                    doorinfo.LatestUploadDate = row.LatestUploadDate;
                    doorinfo.BaseStationName = row.BaseStationName;
                    doorinfo.Detail = row.Detail;
                }
                doorinfos.Add(doorinfo);
            }


            return doorinfos;
        }