Example #1
0
        protected override void ProcessRecord()
        {
            try
            {
                if (String.IsNullOrEmpty(AppId))
                {
                    AppId = InputHelper.GetUserInput(this, "AppId");
                }
                if (String.IsNullOrEmpty(SecretKey))
                {
                    SecretKey = InputHelper.GetUserInput(this, "SecretKey");
                }
                if (String.IsNullOrEmpty(OperationId))
                {
                    OperationId = InputHelper.GetUserInput(this, "OperationId");
                }

                Latch latch = new Latch(AppId, SecretKey);
                WriteObject(latch.RemoveOperation(OperationId), true);
            }
            catch (Exception ex)
            {
                InvokeCommand.InvokeScript(String.Format("Write-Host Error: \"{0}\"", ex.Message));
            }
        }
Example #2
0
        public UmbracoLatchResponse DeleteOperation(int operationId)
        {
            if (!OperationExists(operationId))
            {
                var errorMessage = GetResponseMessage("notFound");
                return(new UmbracoLatchResponse(false, errorMessage));
            }

            var currentOperation = latchRepo.GetOperationById(operationId);
            var application      = GetApplication();
            var latch            = new Latch(application.ApplicationId, application.Secret);
            var response         = latch.RemoveOperation(currentOperation.OperationId);

            // The 301 error code means that the operation wasn't found on Latch
            // so it's probably that the user deleted the operation from the Latch app
            // and we only need to delete it from the local database.
            if (response.Error != null && response.Error.Code != 301)
            {
                var errorMessage = GetResponseMessage("error" + response.Error.Code);
                return(new UmbracoLatchResponse(false, errorMessage));
            }

            latchRepo.DeleteOperation(currentOperation);

            var successMessage = GetResponseMessage("editSuccess");

            return(new UmbracoLatchResponse(true, successMessage));
        }