views:

29

answers:

1

In my model I have relationships like this:

[Person]
 PersonId (PK)
 ...

[Orders]
 OrderId (PK)
 PersonId (FK to Person.PersonId)
 ...

A person can have multiple orders.

I generated PersonController with Create/Details/List/Edit views. I want to be able to manipulate Orders also, but within the context of a Person. In other words, I'd like the workflow to be

  • User browses a list of people (/Persons)
  • User selects 'View Orders' link next to a specific Person (/Persons/4/Orders/)
  • User sees a list of orders with Create/Details/Edit as well (/Persons/4/Orders/Edit/38)

Is this the right way to set up my controllers/routes? Should I just access orders at routes like (/Orders/Edit/38) instead?

Right now I have:

PersonController OrderController

Should I create a PersonOrderController or can I achieve what I want using only the two controllers I already have?

+1  A: 

You should probably use just the two Controllers you already have. It is a judgment call however. Two different excellent MVC designers might do this two different ways. Unless you already see a lot of other work for your OrderController, you should start with two controllers. If OrderController becomes bloated, you can refactor.

Patrick Karcher