public async Task <IPostResponse> AddSensorAcs7120Value([FromContent] SensorAcs712 data) { try { var sensor = await Context.Instance.Connection.Table <wola.ha.common.DataModel.Sensors>().Where(w => w.SensorType == data.SensorType && w.Address == data.Address).FirstOrDefaultAsync(); if (sensor == null) { return(new PostResponse(PostResponse.ResponseStatus.Conflict, $"AddSensorAcs7120Value/{data}")); } ; var value = new SensorOnOffValue { SensorId = sensor.Id, Value = data.Value, Date = DateTime.Now }; var ret = await Context.Instance.Connection.InsertAsync(value); return(new PostResponse(PostResponse.ResponseStatus.Created, $"AddSensorAcs7120Value/{ret}")); } catch (Exception ex) { LoggerFactory.LogException(ex); return(new PostResponse(PostResponse.ResponseStatus.Conflict, $"SensorTemperatureValues/{data}")); } }
public async Task <IPostResponse> AddSensorHumidityValue([FromContent] SensorOnOffValue data) { try { var ret = await Context.Instance.Connection.InsertAsync(data); return(new PostResponse(PostResponse.ResponseStatus.Created, $"SensorOnOffValue/{ret}")); } catch (Exception ex) { LoggerFactory.LogExceptionStack(ex); return(new PostResponse(PostResponse.ResponseStatus.Conflict, $"SensorOnOffValue/{data}")); } }