private void UpdateDeviceStatus(int deviceId, string status) { var item = _context.Devices .FirstOrDefault(d => d.Id == deviceId); _context.Update(item); item.Status = _context.Statuses.FirstOrDefault(s => s.Description == status); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Type,Producer,Model,ReliableUser,Price,Ticket")] Devices devices) { if (id != devices.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(devices); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DevicesExists(devices.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(devices)); }
public async Task <T> Update(T Item) { var result = await Task.FromResult(_dbContext.Update <T>(Item)); await _dbContext.SaveChangesAsync(); return(result.Entity); }
public string ConnectDevice(string name) { Device doorLock = db.DoorLocks.FirstOrDefault(x => x.Name == name); if (doorLock == null) { return("device is not found"); } if (doorLock.IsConect) { return("device is already connected"); } else { doorLock.IsConect = true; db.Update(doorLock); db.SaveChanges(); return("device is connected"); } }
public string ConnectDevice(string name) { Device powerSocket = db.PowerSockets.FirstOrDefault(x => x.Name == name); if (powerSocket == null) { return("device is not found"); } if (powerSocket.IsConect) { return("device is already connected"); } else { powerSocket.IsConect = true; db.Update(powerSocket); db.SaveChanges(); return("device is connected"); } }
public string ConnectDevice(string name) { Device temperatureSensor = db.TemperatureSensors.FirstOrDefault(x => x.Name == name); if (temperatureSensor == null) { return("device is not found"); } if (temperatureSensor.IsConect) { return("device is already connected"); } else { temperatureSensor.IsConect = true; db.Update(temperatureSensor); db.SaveChanges(); return("device is connected"); } }
public string ConnectDevice(string name) { Device heater = db.Heaters.FirstOrDefault(x => x.Name == name); if (heater == null) { return("device is not found"); } if (heater.IsConect) { return("device is already connected"); } else { heater.IsConect = true; db.Update(heater); db.SaveChanges(); return("device is connected"); } }
public string ConnectDevice(string name) { Device lamp = db.Lamps.FirstOrDefault(x => x.Name == name); if (lamp == null) { return("device is not found"); } if (lamp.IsConect) { return("device is already connected"); } else { lamp.IsConect = true; db.Update(lamp); db.SaveChanges(); return("device is connected"); } }