/// <summary> /// Reverts changes made to the water meter reading control is there is an update pending. /// </summary> /// <param name="relationshipViewModel"></param> private void CancelWaterSystemAction(WaterMeterViewModel waterSystemViewModel) { bool undo = false; ChangeSet changeSet = this.dc.GetChangeSet(); foreach (var v in changeSet.Updates) { if (typeof(Property) == v.GetType()) { Property p = v as Property; if (this.SelectedProperty.PropertyID == p.PropertyID) { undo = true; } } if (typeof(WaterMeterReading) == v.GetType()) { WaterMeterReading w = v as WaterMeterReading; if (this.SelectedProperty.PropertyID == w.PropertyID) { undo = true; } } if (undo) { this.dc.Refresh(RefreshMode.OverwriteCurrentValues, v); undo = false; } } }
/* ---------------------------------- Public/Private Methods ------------------------------------------ */ #region Methods /// <summary> /// TO-DO: Move to another VM.... /// Adds new water meter readings to collection /// </summary> /// <param name="relationshipViewModel"></param> private void AddWaterMeetingReadingToCollection(WaterMeterViewModel waterSystemViewModel) { // Since the WaterMeterReading VM is virtual, we copy it back to the main (Properties) VM. // This updates, or copies over, changes a user has made to VM properties of the SelectedProperty //this.SelectedProperty = waterSystemViewModel.SelectedProperty; // However, the MeterReadings are stored in a separate collection, so we have to iterate // over them and add new items to the PropertiesVM in order for them to be registered // in the DC's changeset. //foreach (WaterMeterReading mr in waterSystemViewModel.MeterReadings) //{ // if (0 == mr.RowID) // { // this.SelectedProperty.WaterMeterReadings.Add(mr); // RaisePropertyChanged("WaterDataUpdated"); // } //} }