public async Task <ActionResult> ActivateAsync(int id) { var macro = await _dbContext.GetMacroAsync(id, User.Identity.Name); if (macro == null) { return(NotFound(new { Success = false })); } foreach (var macroDevice in macro.Devices) { macroDevice.Device.Value = macroDevice.Value; await _dbContext.SaveChangesAsync(); } return(Ok(new { Success = true })); }
public async Task <ActionResult> SetDeviceAsync([FromBody] DeviceValue setDevice) { var device = await _dbContext.GetDevices(User.Identity.Name) .FirstOrDefaultAsync(settingDevice => settingDevice.Id == setDevice.Id); device.Value = setDevice.Value; await _dbContext.SaveChangesAsync(); return(Ok(new { id = device.Id, value = device.Value })); }