Example #1
0
        public bool Delete <TBuildingBlock>(IReadOnlyList <TBuildingBlock> buildingBlocksToDelete) where TBuildingBlock : class, IPKSimBuildingBlock
        {
            if (!buildingBlocksToDelete.Any())
            {
                return(true);
            }

            var buildingBlockType = _entityTask.TypeFor(buildingBlocksToDelete.First());

            foreach (var buildingBlockToDelete in buildingBlocksToDelete)
            {
                var simulationsUsingBuildingBlockToDelete = _buildingBlockInSimulationManager.SimulationsUsing(buildingBlockToDelete).ToList();
                if (simulationsUsingBuildingBlockToDelete.Any())
                {
                    throw new CannotDeleteBuildingBlockException(buildingBlockToDelete.Name, buildingBlockType, simulationsUsingBuildingBlockToDelete);
                }
            }

            var viewResult = _dialogCreator.MessageBoxYesNo(PKSimConstants.UI.ReallyDeleteObjectOfType(buildingBlockType, buildingBlocksToDelete.AllNames().ToArray()));

            if (viewResult == ViewResult.No)
            {
                return(false);
            }

            buildingBlocksToDelete.OfType <Simulation>().Each(simulation => _simulationReferenceUpdater.RemoveSimulationFromParameterIdentificationsAndSensitivityAnalyses(simulation));

            var macoCommand = new PKSimMacroCommand
            {
                CommandType       = PKSimConstants.Command.CommandTypeDelete,
                ObjectType        = buildingBlockType,
                BuildingBlockType = buildingBlockType,
                Description       = PKSimConstants.Command.ObjectsDeletedFromProject(buildingBlockType),
            };

            buildingBlocksToDelete.Each(x => macoCommand.Add(DeleteCommand(x)));
            AddCommandToHistory(macoCommand.Run(_executionContext));
            buildingBlocksToDelete.Each(RemovePresenterSettings);

            return(true);
        }
Example #2
0
        protected override IMoBiCommand RunRemoveCommand(IMoBiSimulation simulationToRemove, IMoBiProject parent, IBuildingBlock buildingBlock)
        {
            _simulationReferenceUpdater.RemoveSimulationFromParameterIdentificationsAndSensitivityAnalyses(simulationToRemove);

            return(base.RunRemoveCommand(simulationToRemove, parent, buildingBlock));
        }