public void DeleteCommand(IExplorerTreeItem parent, IExplorerRepository explorerRepository, ExplorerItemViewModel explorerItemViewModel, IPopupController popupController, IServer server) { try { if (explorerItemViewModel.IsResourceVersion) { DeleteVersionCommand(explorerRepository, explorerItemViewModel, parent, explorerItemViewModel.ResourceName); } else { var messageBoxResult = popupController.Show(popupController.GetDeleteConfirmation(explorerItemViewModel.ResourceName)); if (server != null && messageBoxResult == MessageBoxResult.Yes) { _shellViewModel.CloseResource(explorerItemViewModel.ResourceId, server.EnvironmentID); var deletedFileMetadata = explorerRepository.Delete(explorerItemViewModel); if (deletedFileMetadata.IsDeleted) { if (explorerItemViewModel.ResourceType == @"ServerSource" || explorerItemViewModel.IsServer) { server.UpdateRepository.FireServerSaved(explorerItemViewModel.ResourceId, true); } parent?.RemoveChild(explorerItemViewModel); } } } } catch (Exception ex) { explorerItemViewModel.ShowErrorMessage(ex.Message, @"Delete not allowed"); } }
void DeleteCommand(IExplorerTreeItem parent, IExplorerRepository explorerRepository, ExplorerItemViewModel explorerItemViewModel, IPopupController popupController, IServer server) { var messageBoxResult = popupController.Show(popupController.GetDeleteConfirmation(explorerItemViewModel.ResourceName)); if (server != null && messageBoxResult == MessageBoxResult.Yes) { _shellViewModel.CloseResource(explorerItemViewModel.ResourceId, server.EnvironmentID); var deletedFileMetadata = explorerRepository.TryDelete(explorerItemViewModel); if (deletedFileMetadata.IsDeleted) { if (explorerItemViewModel.ResourceType == @"ServerSource" || explorerItemViewModel.IsServer) { server.UpdateRepository.FireServerSaved(explorerItemViewModel.ResourceId, true); } parent?.RemoveChild(explorerItemViewModel); } } }