What is the best place for business logic in ASP.NET MVC when using repositories?

后端 未结 5 1747
醉酒成梦
醉酒成梦 2021-02-02 16:25

When implementing Repository for database in ASP.NET MVC project, is it correct to place business logic into it or may be better to place logic in controller class? Or use addit

5条回答
  •  一向
    一向 (楼主)
    2021-02-02 17:15

    Add a Service Layer to pass models to Repository, where Service classes corresponding to the controller can be added. For example if you use a UserController and User Model, You can pass the User Model to UserService class.

    Here the Service Layer can act as a bridge between the Repository and the controller so that the separation of Controller and Repository is well established.

提交回复
热议问题