I have a constructor signature that looks like this.
public LocateEditorViewModel(
ILocateRepository locateRepository,
int id,
IInteractionService interactionService)
{
As the class name suggests this is the view model I use to edit locates. This view model is created from a factory that injects ILocateRepository and IInteractionService. The id is passed in the factories Create(int id) function.
Is it the job of the LocateEditorViewModel to receive and id of the item I wish to edit and query it from the database. Or should I query for the given item in my factory and replace my int id parameter into a LocateViewModel object?
The ViewModel works on the data of the Model which in turn accesses the database. The ViewModel does not access the database.
So: Yes, you should replace the id with the actual object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With