using eSuite.WorkBench.Services; using eSuite.WorkBench.WpfHelper; using System; using System.Threading.Tasks; namespace eSuite.WorkBench.Commands { public class StopContainersCommand : AsyncCommandBase { private readonly MainWindowViewModel _mainWindowViewModel; private readonly ICommandsService _commandService; public StopContainersCommand(MainWindowViewModel mainWindowViewModel, ICommandsService commandsService, Action onExeception, EventHandler addFeedbackMessage) : base(onExeception) { FeedbackMessage += addFeedbackMessage; _mainWindowViewModel = mainWindowViewModel; _commandService = commandsService; IsEnabled = _commandService.IsAnyContainerRunning(); } protected override async Task ExecuteAsync(object parameter) { DoFeedbackMessage("Stopping containers..."); await _commandService.StopContainersAsync(); IsEnabled = await _commandService.IsAnyContainerRunningAsync(); _mainWindowViewModel.StartContainersCommand.IsEnabled = !(IsEnabled); DoFeedbackMessage("...containers stopped"); } } }