1

I'm a little bit confused how to use area in MVC. I create 2 areas for admin and customer, but admin and customer can access the same controller.

For example, PurchaseOrderController, I'm confused where this controller should be placed, in admin area or customer area?

Customer can create a puchase order, edit a purchase (if it hasn't been processed yet), and show his purchases and the details.

Admin, can see all of the customer purchases and details, process the purchase (update status to in progress)

So, should I create PurchaseOrderController in admin area and customer area? What is your solution about this case?

1 Answer 1

1

It sounds like two completely different process flows. What you have described a separate controller may be necessary for both use cases. Otherwise you might litter your view with if statements for logic that might not technically belong on that screen.

Authorize can be used at both controller and method level, so if you find it doesn't make sense in a seperate controller then merge them into one.

[Authorize(Roles="Administrators")] 
Sign up to request clarification or add additional context in comments.

3 Comments

I just think whether I've implemented areas correctly or does it a good approach we have the same controller in different area?
I would say its better to go separate areas because your view models should be different to the view model for user and administrator despite having some composition that they share. I believe its better to follow separation of concerns even for controllers.
Sorry for late reply. Agreed, but what about the name of controllers? Should they have the same name? Could you give the common example which is usually done by MVC's programmers?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.