-
-
Notifications
You must be signed in to change notification settings - Fork 407
Closed
Labels
Description
Issue
When a business object is changed and saved any subsequent change that is undone will revert to the original fetched value not the last saved value.
Steps to reproduce:
- Using the Blazor ViewModel with the ManageObjectLifetime set to true
- Call the ViewModel RefreshAsync to Fetch an EditableRoot model
- Make a change to a property
- Save the model
- Make a second change to a property
- Cancel the change
- Note that the model property has reverted to the original value and not the value after the save in step 4
Version and Platform
CSLA version: 7.x
OS: Windows
Platform: Blazor
Problems
- We discovered that the ViewModel code performs the ApplyEdit on the clone and not on the model.
- Since the OnModelChanging is not called because the references are the same, the BeginEdit is not called.
Solution
- Created unit test SaveThenCancel_ValidatePropertyValue to reproduce the issue
- We moved the ApplyEdit from after the clone to before the clone so that it is applied to the model.
- Added logic to the finally block of the save to call BeginEdit if the ManagedObjectLifetime is true and the EditLevel is zero.
- SaveThenCancel_ValidatePropertyValue unit test now passes