I have a problem i am trying to solve.
I have a grid (tabular) type layout that will contain a collection of ViewModels
.
I want to be able to validate those ViewModels
and then turn the cells for a given property red if it contains error:
Prop 1 | Prop 2 | Prop 3 | Prop 4
Row 1 x | | x |
Row 2 x | x | | x
Row 3 | x | x |
x = Red Cell
My question is how do I do this using model state that is filled from a service layer?
I am using AutoMapper to map Domain Objects (POCO) to ViewModels, where the POCO's are supplied by a service layer.
So basically:
Controller --> Service --> Returns Domain Object --> Maps to view models --> handed to view.
The business logic is in the service layer and I was thinking of passing in a model state wrapper to the service to fill the model state with errors from the domain objects.
I would assume some sort of key?
I know that model state is per property right?
Thanks!!