예제 #1
0
        private async Task SaveAsync()
        {
            var tasks = new List <Task>();

            // add
            var variablesForAdd = Variables.Where(v => v.Id == default(int)).ToDictionary(v => v.Name, v => v.Value);

            tasks.AddRange(AddVariablesAsync(variablesForAdd));

            // delete
            tasks.AddRange(Client.DeleteEnvironmentVariableAsync(VariablesForDelete));

            // update
            var variablesForUpdate = Variables.Where(v => v.Id != default(int) && v.DirtyService.IsDirty).ToDictionary(v => v.Id, v => v.Value);

            tasks.AddRange(Client.UpdateEnvironmentVariableAsync(variablesForUpdate));

            await Task.WhenAll(tasks);

            DirtyService.MarkClean();
        }
예제 #2
0
        public StateMachineDialogWindowViewModel(
            StateMachine stateMachine,
            IViewService viewService,
            IDirtyService parentDirtyService,
            Action <StateMachine> updateParentModel,
            IMessageBoxService messageBoxService
            )
        {
            _viewService        = viewService ?? throw new ArgumentNullException(nameof(viewService));
            _parentDirtyService = parentDirtyService ?? throw new ArgumentNullException(nameof(parentDirtyService));
            _updateParentModel  = updateParentModel;
            _messageBoxService  = messageBoxService ?? throw new ArgumentNullException(nameof(messageBoxService));

            InitiateStateMachineViewModel(stateMachine);

            _undoService = new UndoService <StateMachine>();
            _undoService.Clear(SaveMomento());

            DirtyService.MarkClean();
            InitializeCommands();
        }