I have a scenario where on a certain view I can have 2 different objects of the same type [Customer]. The first one is called Customer, the other one is called CustomerApprove. The latter contains a change in the customer data to be approved.
If the CustomerApprove object is filled, I want the textbox to contain that value. Otherwise I want to use the normal Customer object value.
I thought of 2 ways to achieve this.
use the @value initializer and an inline IF statement
Html.TextBoxFor(m => Customer.City, new { @Value = somecondition ? CustomerApprove.City : Customer.City })Call a method on the Model to determine which object to use.
Html.TextBoxFor(m => Customer.City, new { @Value = Model.SomeMethodToGetTheValue() })
Which is the better approach to use, or are there any other suggestions?