private void CopyFromOther(VesselViewModel other) { this.Id = other.Id; this.Name = other.Name; this.MaxPassengersCapacity = other.MaxPassengersCapacity; this.BoardedPassengers = other.BoardedPassengers; }
private void OnEditVessel(VesselViewModel vessel) { /* * We can specify the notification content in two ways here: * * 1* If we use "Content = vessel" and pass the selected vessel directly, * any intermediate changes in the Edit window will be applied automatically to the List window * (they're both binding to the same instance). Whenever we cancel (i.e. use IEditableObject.CancelEdit()) * the changes will be reverted and the List window will be back to its original state. * * 2* If we use "Content = new VesselViewModel(vessel)", there's no need to implement * IEditableObject on VesselViewModel, because we're passing a new instance to the * Edit window every time and it will be discarded both on Save and Cancel. * * 3 * another approach is to simply send the id to the interaction request and have it deal with it. * */ this.EditVesselInteractionRequest.Raise(new VesselNotification() { Title = $"Edit {vessel.Name}", Content = vessel, // APPROACH 1 //Content = new VesselViewModel(vessel), // APPROACH 2 EditMode = VesselNotification.EditModes.Edit }, _ => { var __ = this.InitializeAsync(); }); }
public void BeginEdit() { this.memento = new VesselViewModel(this); }
public VesselViewModel(VesselViewModel other) { this.CopyFromOther(other); }
public void EndEdit() { this.memento = null; }