Reputation: 149
I am playing with VSA and I encounter something that seams wrong. I want to build a Web Api using MediatR and CQRS. Now, let's say I want to implement some CRUD operation on an entity called User, that have a list of Cars and the Car have a list of Policies (Just a random example).
If for example I want to do the create flow I need the following models (I am considering sharing MediatR and Api Request, but I got some other problems in that case):
For Search/Get Endpoint I will need again 3 (almost identical - On create I don't have an Id) with the one from create) different classes for responses (If I share MediatR response with the Api Response).
Now let's say I want to add a "Add Car to storage" endpoint. I will need to duplicate the CarDto.cs, PolicyDto.cs and UserRequest.cs, CarRequest.cs classes in order to not use the same models in 2 different features.
In addition to all this I will need a mapper for all of them (UserRequest -> UserDto->User, CarRequest->CarDto->Car etc.).
Is that normal? I feel like I can share some of the classes (e.g. CarDto for both add User and add Car to storage flow), but I would like to have a rule and a consistency across the features.
Upvotes: 0
Views: 24