REST Service and CQRS
- by Paul Wade
I am struggling with architecture on a new project. I am using the following patterns/technology.
CQRS - anything going in goes through a command
REST - using WebAPI
MVC - asp.net mvc
Angular - building a spa
nhibernate
I belive this provides some great separation and should help keep a very complex domain from growing into a giant set of services that mix queries with other business logic.
The REST services have become non restful. They are putting methods in rest that are "SearchByDate", "SearchByItem" etc.
Service Methods that execute commands are called with a "web" model class, a new command is built in the service and executed, I feel like there is a lot of extra code.
I expected this to be much different but I wasn't around to keep things on track.
Finally my questions are this...
I would have liked to see PUT Person (CreatePersonCommand) but then I realized that isn't restful either is it? the put should be a person entity not a command.
Can I make CQRS and REST service work together or am I going about this all wrong?
How do I handle service methods that don't fit into a REST model. I am not performing CRUD on the object but rather executing some business logic. I.E. I don't want the UI to be responsible for how a shipment is "unshipped" I want the service layer to worry about that.