public async Task <IActionResult> PutNotificationFromDevice(int id, NotificationFromDevice notificationFromDevice) { if (id != notificationFromDevice.Id) { return(BadRequest()); } _context.Entry(notificationFromDevice).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NotificationFromDeviceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Device Off(Guid id) { Device device = db.Devices.Find(id); if (device.State == true) { device.Off(); } else { device.On(); } db.Entry(device).State = EntityState.Modified; db.SaveChanges(); return(device); }
public ActionResult Off(Guid id) { Device device = db.Devices.Find(id); if (device.State == true) { device.Off(); } else { device.On(); } db.Entry(device).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <Device> UpdateDevice(Guid id, Device device) { _context.Entry(device).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeviceExists(id)) { return(null); } else { throw; } } return(device); }