///-------------------------------------------------------------------------------- /// <summary>This method updates the view model data and sends update command back /// to the solution builder.</summary> ///-------------------------------------------------------------------------------- protected override void OnUpdate() { // send update for any updated children foreach (DatabaseSourceViewModel item in DatabaseSources) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (DatabaseSourceViewModel item in ItemsToAdd.OfType <DatabaseSourceViewModel>()) { item.Update(); DatabaseSources.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (DatabaseSourceViewModel item in ItemsToDelete.OfType <DatabaseSourceViewModel>()) { item.Delete(); DatabaseSources.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (DatabaseSourceViewModel item in DatabaseSources) { item.ResetModified(false); } }
///-------------------------------------------------------------------------------- /// <summary>This method applies database specification source deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeleteDatabaseSourcePerformed(DatabaseSourceEventArgs data) { bool isItemMatch = false; if (data != null && data.DatabaseSource != null) { foreach (DatabaseSourceViewModel item in DatabaseSources.ToList <DatabaseSourceViewModel>()) { if (item.DatabaseSource.SpecificationSourceID == data.DatabaseSource.SpecificationSourceID) { // remove item from tabs, if present WorkspaceEventArgs message = new WorkspaceEventArgs(); message.ItemID = item.DatabaseSource.SpecificationSourceID; Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message); // delete item isItemMatch = true; DatabaseSources.Remove(item); Solution.DatabaseSourceList.Remove(item.DatabaseSource); Items.Remove(item); Solution.ResetModified(true); OnUpdated(this, null); break; } } if (isItemMatch == false) { ShowIssue(DisplayValues.Issue_DeleteItemNotFound); } } }