문제

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

The logic happens when creating records, based on certain fields of that record other records need to be created.

I'm currently using the repository pattern with an ORM and the easiest place to put this logic would be in my repository class but I feel like this is a pretty feeble location to have important rules, I would put it directly in my partial model classes that have my validation and metadata but I then have to call methods within my controller or repository and that may be extending too much knowledge about implementation to those layers.

What are your best practice tips for me?

Thanks!

도움이 되었습니까?

해결책

You could have a service layer between the controller and the repositories. The repository performs simple CRUD operations with your model. A service method could make use of multiple simple repository calls to compose a business operation. This business operation will be exposed to the controller.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top