protected virtual bool Save(IContextualResourceModel resource, bool isLocalSave, bool addToTabManager = true, bool isStudioShutdown = false)
        {
            if (resource == null || !resource.UserPermissions.IsContributor())
            {
                return(false);
            }


            FindMissing();

            if (DataListViewModel != null && DataListViewModel.HasErrors)
            {
                PopupController.Show("Please resolve the variable(s) errors below, before saving." + System.Environment.NewLine + System.Environment.NewLine + DataListViewModel.DataListErrorMessage, "Error Saving", MessageBoxButton.OK, MessageBoxImage.Error, "true");

                return(false);
            }

            if (resource.IsNewWorkflow && !isLocalSave)
            {
                _saveDialogAction(resource, addToTabManager);
                // ShowSaveDialog(resource, addToTabManager);
                return(true);
            }


            BindToModel();

            var result = _workspaceItemRepository.UpdateWorkspaceItem(resource, isLocalSave);

            // shutdown - just save to workspace
            if (isStudioShutdown)
            {
                return(true);
            }

            resource.Environment.ResourceRepository.Save(resource);
            DisplaySaveResult(result, resource);
            if (!isLocalSave)
            {
                ExecuteMessage saveResult = resource.Environment.ResourceRepository.SaveToServer(resource);
                DispatchServerDebugMessage(saveResult, resource);
                resource.IsWorkflowSaved = true;
                StudioResourceRepository.RefreshVersionHistory(resource.Environment.ID, resource.ID);
            }
            return(true);
        }