Where do I put controller in logic?

Where do I put controller in logic?

The business logic should be placed in the model, and we should be aiming for fat models and skinny controllers. As a start point, we should start from the controller logic. For example: on update, your controller should direct your code to the method/service that delivers your changes to the model.

Where does the main logic go in a basic MVC application?

A1: Business Logic goes to Model part in MVC . Role of Model is to contain data and business logic. Controller on the other hand is responsible to receive user input and decide what to do.

Do you need business logic in a controller?

In this tutorial, Stephen Walther explains how you can maintain a sharp separation of concerns by isolating your service layer from your controller layer. Business Logic should not be contained in controllers. Controllers should be as skinny as possible, ideally follow the patter: Additionally controllers can contain some application logic.

How much logic should be in the controller layer?

But you should never place domain logic in the controller layer. That should obviously be in the domain layer. You were talking about logic to format or sanitize data. Formatting must definately be application logic. Sanitizing on the other hand could be domain logic, if sanitizing data is based on domain rules.

What happens if you mix database and controller logic?

Mixing your database and controller logic makes your application more difficult to maintain over time. The recommendation is that you place all of your database logic in a separate repository layer. For example, Listing 1 contains a simple repository named the ProductRepository.

How is business logic related to application logic?

Application logic is logic related to the fact that you are running a computer program. This can be stuff such as CSV import export, wizards, etc. Could also contain stuff like creating forgotten password emails. The kind of “business logic” that you can place in the controller layer is Application logic.