Ejemplo n.º 1
0
        public async Task <IActionResult> ManualCloudConnect([FromBody] ManualCloudConnectRequest connectRequest)
        {
            if (await _cloudHandler.IsConnected() && !connectRequest.force)
            {
                // Bruh, we're connected
                _response.Errors.Add(Errors.CLOUD_ALREADY_CONNECTED, true);
                _response.Errors.Add(Errors.FORCE_PARAMETER_REQUIRED, true);

                return(BadRequest(_response));
            }

            // Well ok, let's get it over with.
            await CreateOrUpdateConfig(ConfigKeys.CloudConnectStatus, true.ToString());
            await CreateOrUpdateConfig(ConfigKeys.CloudConnectIdentifier, connectRequest.NodeId.ToString());
            await CreateOrUpdateConfig(ConfigKeys.CloudConnectNodeKey, connectRequest.NodeKey);

            ManageBackgroundJob();

            return(await LocalStatus());
        }
 public bool IsEnabled()
 {
     return(_cloudHandler.IsConnected().Result); // Async sadness :(
 }