///-------------------------------------------------------------------------------- /// <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 (PropertyReferenceViewModel item in PropertyReferences) { if (item.IsEdited == true) { item.Update(); } } // send update for any new children foreach (PropertyReferenceViewModel item in ItemsToAdd.OfType <PropertyReferenceViewModel>()) { item.Update(); PropertyReferences.Add(item); } ItemsToAdd.Clear(); // send delete for any deleted children foreach (PropertyReferenceViewModel item in ItemsToDelete.OfType <PropertyReferenceViewModel>()) { item.Delete(); PropertyReferences.Remove(item); } ItemsToDelete.Clear(); // reset modified for children foreach (PropertyReferenceViewModel item in PropertyReferences) { item.ResetModified(false); } }
///-------------------------------------------------------------------------------- /// <summary>This method applies propertyreference deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeletePropertyReferencePerformed(PropertyReferenceEventArgs data) { try { bool isItemMatch = false; if (data != null && data.PropertyReference != null) { foreach (PropertyReferenceViewModel item in PropertyReferences.ToList <PropertyReferenceViewModel>()) { if (item.PropertyReference.PropertyID == data.PropertyReference.PropertyID) { // remove item from tabs, if present WorkspaceEventArgs message = new WorkspaceEventArgs(); message.ItemID = item.PropertyReference.PropertyID; Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message); // delete children for (int i = item.Items.Count - 1; i >= 0; i--) { } // delete item isItemMatch = true; PropertyReferences.Remove(item); Entity.PropertyReferenceList.Remove(item.PropertyReference); Items.Remove(item); Entity.ResetModified(true); OnUpdated(this, null); break; } } if (isItemMatch == false) { ShowIssue(DisplayValues.Issue_DeleteItemNotFound); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }
///-------------------------------------------------------------------------------- /// <summary>This method deletes an instance of PropertyReference from the view model.</summary> /// /// <param name="itemView">The PropertyReference to delete.</param> ///-------------------------------------------------------------------------------- public void DeletePropertyReference(PropertyReferenceViewModel itemView) { itemView.Updated -= Children_Updated; PropertyReferences.Remove(itemView); Delete(itemView); }