开发者

create wizard form in MVC and how to manage view and controller folders

i need to make a form wizard of 3 steps. Each steps can be saved in the database separatly. The steps will be to enter information about an Company, then his Publications and finally his Reservations.

Should i put all the logics in one controller or different controllers? My first thought would be in one controller since this is all about managing a company but the problem with that is i will 开发者_StackOverflow社区have a lot of code in the controller and in the View folder, i will have like 20 webpages.

Is there a way to put subfolders in the View\Companies\ folder so i could have View\Compangies\Publications. That way, i can separate the web pages for each theme.

Or how do you manage that? Is there a better way to handle properly Wizard Forms?

alex


Depends on the Model. If your Publications are their own entity and they eventually get stored (in DB) in their own table, it might be the proper way for them to have their own controller. The same with Reservations. If you store both of those as a part of the Company entity then it might be better for them to stay in Company controller. But it seems to me that they ought to be separate.

With regards to redirection between controller actions you can always use RedirectToAction() to redirect inside the same controller.

You can also use MVC Futures project and their RedirectToAction() extensions with which you can also redirect between different controllers.

FWIW, I think that if you are editing Publication that has its own properties etc. it belongs in their own Entity and as such they need to have their own Model, Controller and subsequently Views (in a separate View folder at the root of Views).

UPDATE:

What's wrong with a route looking like this:

Creating a publication for a company with {companyId}

/Publication/Create/{companyId}

or

Editing a publication with an id {publicationId} and for a company with {companyId}

/Publication/Edit/{companyId}/{publicationId}

or if publication ID's are unique regardless of the company

/Publication/Edit/{publicationId}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜