Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi, my manager has asked me to develop an application in .net mvc and entity framework. I know how to create the app in .net mvc and entity framework, but I want to make the solution loosely coupled. Also I would like to add roles in the application. For example the admin will get to edit and inserting master data permissions and some other screens as well and normal user will be able to see and edit data. How should I proceed with this requirement. Are there any existing tutorials for the same.

What I have tried:

Right now I'm just writing everything in controller like getting the list of accounts, inserting, updating and deleting. Also I'm creating object of the entities in each and every controller and its function to get the result. For roles I have created different different view for different roles. Is this a good approach?
Posted
Updated 30-Jan-19 7:14am
v2
Comments
BillWoodruff 30-Jan-19 2:35am    
Do not double-post: revise your original question as needed.

I always found this was a good place to start:

The Onion Architecture : part 1 | Programming with Palermo[^]
 
Share this answer
 
v3
Comments
Sachin Gotal 30-Jan-19 4:37am    
Hi, thank you for providing me with this approach. If you have a tutorial where in this approach is explained with the help of project, then it would be really helpful. Thanks again.
Wastedtalent 30-Jan-19 4:58am    
https://blog.thedigitalgroup.com/understanding-onion-architecture might be of some use?
Sachin Gotal 6-Feb-19 4:34am    
Thank you very much :)
Try researching a repository pattern for your API.

Isolate your data access into a single layer of repository code.
Isolate your business rules into a single layer of engine code
Isolate your interface to the API with a controller/service layer
Keep all of your data transfer objects and entity definitions in a domain layer.


Expose your API by defining data transfer objects ( Views ) to a front end.
This produces a loosely coupled API, that is testable at each layer, and allows you to build front end functionality with anything that can consume JSON.
 
Share this answer
 
Comments
Sachin Gotal 6-Feb-19 4:35am    
Thank you :) Will take a look at repository pattern.

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