Hi. The question title might not be clear but what I want to do is something like this:
This is how I layer out my app
App.Domain App.Services App.Web
What I want is, if I request something like /api/OrderProcessor/GetAllOrder
it will call method GetAllOrder
in App.Services.OrderProcessorService
.
The method will return an IList<Order>
and i would like it to be serialized into JSON according to a certain format (I'm using ExtJS actually), to maybe something like:
{
success: true,
totalCount: 10,
list: [ { ... }, { ... } ]
}
I can go on and make the Services as Controllers, but I don't want the service layer to be tainted with presentation stuff.
How can I go about making a wrapper controller like this?
I don't want to attach any attributes on the Service class itself, and would probably be nice if I can configure it using IoC, where by maybe later on I want the output be XML or maybe the ability to use a DTO class instead of the original Domain class.
Any idea?