public async Task <IActionResult> Get2([FromBody] Device2 arduino) { using var _context = new WebAppContext(); var device = await _context.Devices2.FindAsync(arduino.MAC); device.LastUpdate = DateTime.Now; try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { return(StatusCode(500)); //Internal server error } return(Ok(new { device.State1, device.State2 })); }
private static Contracts.Models.TrackerData CreateTrakerData(Company company, Device2 device) { var aggregatedTemperature = AggregateCrumbData("TEMP", device); var aggregatedHumidty = AggregateCrumbData("HUM", device); var normalizedTracker = new NormilizedTracker { TrackerId = device.DeviceID, TrackerName = device.Name }; return(TrackerDataNormalizer.CreateTrakerData(company, normalizedTracker, aggregatedTemperature, aggregatedHumidty)); }
public DeviceViewModel2(Device2 device) { _device = device; }