Example #1
0
 public virtual void OnMessage(MqttApplicationMessageReceivedEventArgs eventArgs)
 {
     _context.SensorData.Add(new SensorData
     {
         Payload   = Encoding.UTF8.GetString(eventArgs.ApplicationMessage.Payload),
         Topic     = eventArgs.ApplicationMessage.Topic,
         TimeStamp = DateTime.UtcNow
     });
     _context.SaveChanges();
 }
Example #2
0
        public void AddSensorData(string topic, string value)
        {
            SensorData data = new SensorData();

            data.Payload   = value;
            data.Topic     = topic;
            data.TimeStamp = DateTime.UtcNow;
            //_context.SensorData.Add({

            //})
            _context.SensorData.Add(data);
            _context.SaveChanges();
        }