public async Task <bool> UpdateBulbStatus(BulbState bulbState, bool?isOn, FaultCode?fault = default(FaultCode?), BulbData bulbData = null) { // get the current state var hasUpdate = false; if (bulbData != null) { bulbState.BulbCurrentState = bulbData; hasUpdate = true; } if (isOn.HasValue) { bulbState.BulbCurrentState.IsOn = isOn.Value; hasUpdate = true; } if (fault.HasValue) { bulbState.BulbCurrentState.FaultCondition = fault.Value; hasUpdate = true; } if (hasUpdate) { var bulb = await GetTask(DbData.Bulbs.Single(x => x.BulbInformation.Id == bulbState.BulbInformation.Id)); bulb.BulbCurrentState = bulbState.BulbCurrentState; return(true); } else { return(true); } }
public async Task <bool> UpdateBulbStatus(Guid bulbId, bool?isOn, FaultCode?fault = default(FaultCode?), BulbData bulbData = null) { var bulb = await GetBulbState(bulbId); return(await UpdateBulbStatus(bulb, isOn, fault, bulbData)); }