I have a Person DB table that has a surname, name, and IdCity fields.
In the View, I’ve implemented an autocomplete field to let the user digit the city.
How should I design the ViewModel for handling the IdCity and how can I pass it to the controller? It is a string but I need to pass the id and eventually insert it in the DB if it does not exist there yet.
Receive the city name in your view action, then look if a city exists for this name. If it does, use its ID. If it doesn’t create a new one, and use that ID: