Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have tables in DB.

1. Supplier
2. Product
3. Company
4. Purchase Order
5. Goods Receive Note

"Purchase Order" have the foreign keys
(i)Supplier_Id   (ii)Product_Id  (iii)Company_Id.
I have created service classes for Supplier, Product, Company & Purchase Order.
These service classes help me to perform CRUD operations using Entity Framework and all other logic is in it.

Now I'm confuse how to create my controllers. Should I create separate controllers for each entity like SupplierController, ProductController or should I create a single controller like StockController and manage all operations in this controller.

What I have tried:

I have created separate controllers for each entity but I'm not sure its the best way or not.
Posted
Updated 8-Oct-17 22:59pm
v3

1 solution

"Controllers" is MVC strictly correspond to views of your application and do what you want in your view. I think by "controllers" you mean the business logic for your entities. If you have created separate business classes for each entity, then that is the way to do it in entity framework. That is how it should be.
As controllers go, you can refer to any number of these business classes to achieve what you want, there are no technical restrictions.

For more information, visit this CP article.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900