Ideal place to put BusinessLogic
See original GitHub issueSo, I am using this template quite a while now. Right now the there are only CRUD application scenarios in this template, where you just request for the data from one domain and then via meditr the request is raised and you get the new data.
But I am looking for more complex scenarios. Consider a situation where we need to get or put data from/to multiple domain objects and then do some operations on both of the data and pass that data to view to display, then how this template gonna handle this situation. As we know we cannot call another query handler method from one query handler method, which is not good approach and it has been discussed in many of the issues in this repository and as well as in NWT repository.
And also we cannot put our business logic in our controller because that will make it’s less reusable and will make our controllers fat which we have to avoid.
So while I was thinking about this issue, I do have a better approach to doing it. So we don’t have any service layer in between the controllers so we can introduce it and can write the custom business logic there and in that, we can have meditr calls to CQRS objects for data. This will make separation of BL from other layer as well and also it will be reusable. So it is just my approach to doing it, I really wanna other people thoughts.
public class BusinessLogicService
{
public List<TodoUser> GetTodosAndUsersDetails(IMeditor m)
{
var users = m.Send(new GetAllUsers());
var todos = m.Send(new GetAllTodos());
// Apply logic and return the result to the controller call
return new List<TodoUser>();
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (6 by maintainers)
I think you misunderstood my comment. I’m saying don’t use two handlers at all, put everything you’re talking about with employee and manager in one handler.
It’s perfectly fine to load data from multiple sources, from a single handler.
Validation and authorisation are two different things and should be kept separate.
Given what you’re asking has nothing to do with this project, If you’d like to post a question on StackOverflow, I’d be happy to answer there.