public Reading Delete(int id)
        {
            Reading reading = GetById(id);

            _context.Readings.Remove(reading);
            _context.SaveChanges();
            return(reading);
        }
Beispiel #2
0
        public ActionResult Post([FromBody] Data data)
        {
            if (!_macs.ContainsKey(data.PhysicalAddress))
            {
                return(NotFound());
            }

            var reading = new Reading
            {
                Device      = _macs[data.PhysicalAddress],
                Temperature = data.Temperature,
                Humidity    = data.Humidity,
                Pressure    = data.Pressure,
                Created     = DateTime.UtcNow
            };

            _readingContext.Readings.Add(reading);
            _readingContext.SaveChanges();

            return(Ok());
        }