question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ideal place to put BusinessLogic

See original GitHub issue

So, 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:closed
  • Created 4 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
GFoley83commented, Feb 27, 2020

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.

2reactions
GFoley83commented, Mar 19, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Project structure: where to put business logic
Project structure: where to put business logic · Data model (DTOs) · Data Access Layer (Persistence) · Web Services layer (Usually one class...
Read more >
domain driven design - Where to put business logic in DDD
Let's say I'm building a fairly complex three layer application and I want to use DDD. My question is, where should I place...
Read more >
What business logic is and where it should live
Business logic is all about the expectations, results and objectives that software, automation or data process need or wish to achieve.
Read more >
The right way to place business logic in your React ...
The good thing about class is that it aggregates all the related logic into one piece, making it isolated and easy to maintain....
Read more >
Where should server-side business logic be located?
Business logic often resides on the server, even if you have it on your client you almost always need to replicate it on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found