Esempio n. 1
0
        public DataConflictVM(EditSubstationVM vm, Window view)
        {
            editSubsVM = vm;
            this.view  = view;

            overrideChangesCmd = new OverrideChanges(this);
            discardChangesCmd  = new DiscardChanges(this);
        }
        public void CanDiscardChanges_should_not_throw_exception_if_pending()
        {
            SetupSingleton(false);

            var command = new DiscardChanges();

            GuardContent.CanDiscardChanges(true, command);
        }
Esempio n. 3
0
        public static void CanDiscardChanges(bool isPending, DiscardChanges command)
        {
            Guard.NotNull(command, nameof(command));

            if (!isPending)
            {
                throw new DomainException("The content has no pending changes.");
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> DiscardDraft(string app, string name, Guid id)
        {
            await contentQuery.GetSchemaOrThrowAsync(Context, name);

            var command = new DiscardChanges {
                ContentId = id
            };

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Esempio n. 5
0
        public async Task <IActionResult> DiscardChanges(string app, string name, Guid id)
        {
            await contentQuery.ThrowIfSchemaNotExistsAsync(Context().WithSchemaName(name));

            var command = new DiscardChanges {
                ContentId = id
            };

            await CommandBus.PublishAsync(command);

            return(NoContent());
        }
Esempio n. 6
0
        public static void CanDiscardChanges(bool isPending, DiscardChanges command)
        {
            Guard.NotNull(command, nameof(command));

            Validate.It(() => "Cannot discard pending changes.", error =>
            {
                if (!isPending)
                {
                    error(new ValidationError("The content has no pending changes."));
                }
            });
        }
Esempio n. 7
0
        public async Task DiscardChanges_should_update_properties_and_create_events()
        {
            var command = new DiscardChanges();

            await ExecuteCreateAsync();
            await ExecutePublishAsync();
            await ExecuteProposeUpdateAsync();

            var result = await sut.ExecuteAsync(CreateContentCommand(command));

            result.ShouldBeEquivalent(new EntitySavedResult(3));

            Assert.False(sut.Snapshot.IsPending);

            LastEvents
            .ShouldHaveSameEvents(
                CreateContentEvent(new ContentChangesDiscarded())
                );
        }
Esempio n. 8
0
        public void CanDiscardChanges_should_throw_exception_if_pending()
        {
            var command = new DiscardChanges();

            Assert.Throws <DomainException>(() => GuardContent.CanDiscardChanges(false, command));
        }
Esempio n. 9
0
 public void DiscardChanges(DiscardChanges command)
 {
     RaiseEvent(SimpleMapper.Map(command, new ContentChangesDiscarded()));
 }
Esempio n. 10
0
        /// <summary>
        /// Closes the project and associated modeless dialogs.  Unsaved changes will be
        /// lost, so if the project has outstanding changes the user will be given the
        /// opportunity to cancel.
        /// </summary>
        /// <returns>True if the project was closed, false if the user chose to cancel.</returns>
        private bool DoClose()
        {
            Debug.WriteLine("ProjectView.DoClose() - dirty=" +
                            (mProject == null ? "N/A" : mProject.IsDirty.ToString()));
            if (mProject != null && mProject.IsDirty)
            {
                DiscardChanges dlg = new DiscardChanges();
                bool?          ok  = dlg.ShowDialog();
                if (ok != true)
                {
                    return(false);
                }
                else if (dlg.UserChoice == DiscardChanges.Choice.SaveAndContinue)
                {
                    if (!DoSave())
                    {
                        return(false);
                    }
                }
            }

#if false
            // Close modeless dialogs that depend on project.
            if (mShowUndoRedoHistoryDialog != null)
            {
                mShowUndoRedoHistoryDialog.Close();
            }
            if (mShowAnalysisTimersDialog != null)
            {
                mShowAnalysisTimersDialog.Close();
            }
            if (mShowAnalyzerOutputDialog != null)
            {
                mShowAnalyzerOutputDialog.Close();
            }
            if (mHexDumpDialog != null)
            {
                mHexDumpDialog.Close();
            }
#endif

            // Discard all project state.
            if (mProject != null)
            {
                mProject.Cleanup();
                mProject = null;
            }
            mDataPathName    = null;
            mProjectPathName = null;
#if false
            mSymbolSubset                = new SymbolTableSubset(new SymbolTable());
            mCodeViewSelection           = new VirtualListViewSelection();
            mDisplayList                 = null;
            codeListView.VirtualListSize = 0;
            //codeListView.Items.Clear();
            ShowNoProject();
            InvalidateControls(null);
#endif
            mMainWin.ShowCodeListView = false;

            mGenerationLog = null;

            // Not necessary, but it lets us check the memory monitor to see if we got
            // rid of everything.
            GC.Collect();

            return(true);
        }