In our Winui3 application, we are following MVVM architecture. I have InvoiceData
, InvoiceModel
, InvoiceViewModel
and InvoiceService
for my Invoice
module.
When saving an Invoice
from the view model, I need to convert the InvoiceModel
to InvoiceData
to hit the API. Converting the model to data depends on a few other properties in the view model.
Let us say if the IsXFeatureEnabled
/IsXFeatureVisible
property in the view model is true, then I need to copy 5 properties in the model to data, else I will ignore them. I cannot have those feature properties in the model as it is meta and needed for UI visibility.
In the above case, can I have the model to data conversion in the view model layer itself, so that I can access all the needed properties directly and pass the resultant data object to the InvoiceService
, which will take care of the further API handling.
The reason for this query is that the MVVM sample project by Microsoft has those conversion methods in the service layer (https://github.com/microsoft/InventorySample). Is moving those methods to view model against the architecture rules?
1