views:

62

answers:

1

Database

This is database structure. It is used to build simple cms in asp.net mvc. Before I run deeper into developing site, I want to make sure if this would be "correct" web structure:

Articles:

  • Controllers folder: Create controllers ArticleCategoryController and ArticleController
  • Models folder: ArticleCategoryRepository and ArticleRepository
  • View folder: ArticleCategory folder (Create.aspx, Edit.aspx, Index.aspx, Details.aspx); Article folder (Create.aspx, Edit.aspx, Index.aspx, Details.aspx)

Photos:

  • Controllers folder: Create controllers PhotoAlbumController and PhotoController
  • Models folder: PhotoAlbumRepository and PhotoRepository
  • View folder: PhotoAlbum folder (Create.aspx, Edit.aspx, Index.aspx, Details.aspx); Photo folder (Create.aspx, Edit.aspx, Index.aspx, Details.aspx)

and so on...
Is there a better way or this is ok?


Thanks.
Ile

+2  A: 

There are lots of ways to organize your controllers and views. I usually create a controller for each full view.

The main comment I have here is about the model. I do not like putting model code into the models folder of the mvc web project unless they are view models or somehow directly related to the web tier of my app and inapplicable to a non web context. In my opinion, you are better off putting things like domain classes, repositories services, etc in a separate assembly or group of assemblies. This way you can swap out the front end with silverlight, or some other technology and continue to leverage your core domain code. Not only is this beneficial for swapping out front ends which is sometimes rare, but you can use the core domain dll for batch files or command line utilities if you ever need to do batch type operations outside of the context of your website.

Matt Wrock
This is going to be one very simple cms... I followed nerddinner tutorial - that's why my repositories are in models folder. I wouldn't go to far with complicating my life, I'm at the very beginning of asp.net mvc so I would stick to basic structure rules. I just wanted to know if Controllers and Views folder, for this project are organized correctly. Thanks for your comment!
ile