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); }
public static void CanDiscardChanges(bool isPending, DiscardChanges command) { Guard.NotNull(command, nameof(command)); if (!isPending) { throw new DomainException("The content has no pending changes."); } }
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)); }
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()); }
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.")); } }); }
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()) ); }
public void CanDiscardChanges_should_throw_exception_if_pending() { var command = new DiscardChanges(); Assert.Throws <DomainException>(() => GuardContent.CanDiscardChanges(false, command)); }
public void DiscardChanges(DiscardChanges command) { RaiseEvent(SimpleMapper.Map(command, new ContentChangesDiscarded())); }
/// <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); }