Is passing the Model around in this way considered bad practice?
Posted
by
Theomax
on Programmers
See other posts from Programmers
or by Theomax
Published on 2012-11-20T20:01:28Z
Indexed on
2012/11/20
23:20 UTC
Read the original article
Hit count: 191
If I have a view called, for example, ViewDetails
that displays user information in labels and has a Model called ViewDetailsModel
and if I want to allow the user to click a button to edit some of these details, is it considered bad practice is I pass the entire Model in the markup to a controller method which then assigns the values for another model, using the values stored in the Model that was passed in as a parameter to that action method? If so, should there instead be a service method that gets the data required for the edit view?
For example:
In the ViewDetails
view, the user clicks the edit button which calls an action method in the controller (and passes in the Model object).
The action method then uses the data in the Model object to populate another model which will be used for the EditDetails
view that will be returned.
© Programmers or respective owner