public async Task <bool> ApplyUpdatesToStorage(IReadOnlyList <DeviceStatusCommand> updates, int expectedversion)
        {
            int version = 0;

            try
            {
                foreach (var item in updates)
                {
                    await runtimeStorage.SaveDeviceState(item.CreateDeviceStateHistory(State.DeviceId, State.DeviceName));

                    version = item.Version.Value;
                }
            }
            catch (Exception e)
            {
                logger.LogError(e, "Error applying updates to storage");
                return(false);
            }

            return(version == expectedversion);
        }