Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Application design. Separation of concerns

Back to Forum: Tech Off
  • User profile image

    I'm building a quite simple ASP.NET MVC application. And there are some things that confuse me a little bit. Let me list what I've got:

    • I've created an API area which provides Products, Categories lists as json; it contains two controllers ProductController and CategoryController.
    • On the client side I'm using Backbone.js and Home->Index.cshtml view as main application page. 
    • Also I've created Admin area which also contains two controllers (ProductController and CategoryController).

    I can't decide how do I implement Admin area. I've been thinking about implementing just one entry point where administrator accesses lists of products, categories, orders etc. and edits them. 

    But! url areas/admin/home/index looks wierd. home/index segment sounds meaningless. 

    Should I split Admin area by adding a controller per entity? Or is it better to have no areas at all and to have admin controller with authorization attribute applied?

    Need an advice. How is that implemented in real world projects?

  • User profile image

    I've seen different views used for the "admin case." Aka...if loggedIsUser.isAdmin? show edit controls. After all, admin responsibilities include full crud of your resources, so your controller will already have all the possible CRUD actions - it would just be a matter of authorizing the user to use those actions. This would be done in two steps: 1.) show the admin controls on the page if the user is an admin 2.) allow the admin to access privileged controller actions.

    This scheme is also really good for code reuse as you're sharing UI elements between two views.

  • User profile image

    You aren't forced to use the default MVC routes. Create your own that will take the areas/admin/ url and forward it to the areas/admin/home/index request.

  • User profile image

    Since Home is the default controller and index is the default action name, going to /admin is the same as /admin/home/index

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.