Background
I'm learning the ropes around how to use ASP.NET MVC properly, and ran into this issue with models:
I have a model that describes a contact
I can get that out of the form for creating a new contact
, but say when we edit a form, I retrieve it from the repository, show the fields on the contact form and then get the contact
object and send that to the model.
Problem
I have a business rule that some fields are not allowed to be edited after creation and other fields are only available after editing.
I receive a dirty object from the user (one with fields they should touch) and using the MVC Binding method (sspecifying the object in the method signature) the users inserts a non-editable field contact_dob
.
Question
Should I instead retrieve the record again, overwrite only the fields I want to update and then send it to the database?
What's the best method when I don't want to retrieve the Entire object again from the database, do I just redo another
EntityModel
that's a lighter version of the main model and use that back and forth?Am I going about this the wrong way? What are the best practices for limiting what users can edit?