public ResultInfo.Result Add(long deviceID, string value, deviceIOType ioType) { DeviceIO endIO = new DeviceIO(); endIO.DeviceID = deviceID; endIO.Valu = value; endIO.IOTypeID = long.Parse(ioType.GetHashCode().ToString()); endIO.TimeStamp = DateTime.Now; db.DeviceIOs.Add(endIO); db.SaveChanges(); return ResultInfo.GenerateOKResult(); }
public static APIDeviceIO FromDeviceIO(DeviceIO sourceDeviceIO) { APIDeviceIO result = new APIDeviceIO(); result.ID = sourceDeviceIO.ID; result.DeviceID = long.Parse(sourceDeviceIO.DeviceID.ToString()); result.IOTypeID = long.Parse(sourceDeviceIO.IOTypeID.ToString()); result.Valu = sourceDeviceIO.Valu; result.TimeStamp = DateTime.Parse( sourceDeviceIO.TimeStamp.ToString()); result.ExecTimeStamp = sourceDeviceIO.ExecTimeStamp; result.ScheduleTimeStamp = sourceDeviceIO.ScheduleTimeStamp; return result; }
public ResultInfo.Result Add(long deviceID, string value, deviceIOType ioType, DateTime executionTime) { try { DeviceIO endIO = new DeviceIO(); endIO.DeviceID = deviceID; endIO.Valu = value; endIO.IOTypeID = long.Parse(ioType.GetHashCode().ToString()); endIO.TimeStamp = DateTime.Now; endIO.ExecTimeStamp = executionTime; db.DeviceIOs.Add(endIO); db.SaveChanges(); return ResultInfo.GenerateOKResult("Saved", endIO.ID); } catch { return ResultInfo.GetResultByID(1); } }