ASP.NET MVC 2 Where to put the logic

I have an ASP.NET MVC 2 application with some complex business rules, and I'm trying to decide where to put the specific logic.

Logic arises when creating records, based on certain fields of this record, you need to create other records.

I am currently using a repository template with ORM, and the easiest place to put this logic in my repository class is, but I feel like this is a pretty weak spot where there are important rules, I would put it directly into my partial model classes, which have my checks and metadata, but then I need to call methods in my controller or repository, and this can increase too much implementation knowledge for these layers.

What are your best practice tips for me?

Thank!

+3
source share
1 answer

You may have a service level between the controller and the repositories. The repository performs simple CRUD operations with your model. A service method can use several simple repository calls to create a business transaction. This business transaction will be available to the controller.

+4
source

Source: https://habr.com/ru/post/1783480/


All Articles