public void Edit(Guid id, int nodeType, [FromBody] FormCollection collection) { if (!ModelState.IsValid) { return; } switch (nodeType) { case 0: var factory = DeviceFactoryViewModel.GetDeviceFactory(id); UpdateModel(factory); factory.Save(); break; case 1: var group = DeviceGroupViewModel.GetDeviceGroup(id); UpdateModel(group); group.Save(); break; case 2: var info = DeviceInfoViewModel.GetDeviceInfo(id); UpdateModel(info); info.Save(); break; case 3: var data = DeviceDataViewModel.GetDeviceData(id); UpdateModel(data, new[] { "unit", "upper", "lower", "AlarmAble", "address", "lengthOrIndex", "group", "type", "id", "groupIndex", "parentId", "index", "name" }); data.Save(); break; case 4: var format = DeviceDataFormatViewModel.GetDeviceDataFormat(id); UpdateModel(format); format.Save(); break; } // TODO: Add update logic here }
// GET api/<controller>/5 public DeviceDataViewModel Get(Guid id) { return(DeviceDataViewModel.GetDeviceData(id)); }
// GET api/<controller> public DeviceDataViewModel Get() { return(DeviceDataViewModel.GetDeviceData().ElementAt(0)); }