Before I ask my question: I just started ASP.NET MVC, so an advanced answer will maybe hard to understand ;)
I'm having 3 tables (I'll add just a few of the fields below)
- Shops (ShopID, Name)
- Products (ProductID, Name, ShopID)
- Comments (CommentID, ProductID, UserID, CommentText)
Now what I want to do is this:
www.site.com/Shops
//Gives me a list of shops
www.site.com/Shops/ShopName
//Gives me some details about the shop called ShopName and lists all the products that the shop has
www.site.com/Shops/ShopName/ProductName/
//Gives me all the comments of that product called ProductName from that specific shop called ShopName
www.site.com/Shops/ShopName/ProductName/ASpecificCommentHere
//Gives me a specific comment on that product of that shop
and other things like
www.site.com/Shops/ShopName/ProductName/AddComment
//Adds a new comment to that product from that shop
Now I only have a ShopsController which makes it possible for me to do something like this now:
www.site.com/Shops/
// Gives me a list of all shops
and
www.site.com/Shops/Details/123
// Gives me some details about the shop with ID 123 and should list its products.
But here is also the first problem: I don't want the ID number in the url like /Shops/123 but rather the name like /Shops/ShopName and I don't know if it's good to have /Details/ there in the url. Maybe /Shops/ShopName would be better without the Details part in between?
How should I do this? Should I create also a Controller for my Products and for my Comments that I have 3 controllers in total? Or should I just keep one ShopController to always get the first part of the url (so that it always starts with) site.com/Shops/ShopName/...
Thanks in advance
(and a short little question, should ViewModels be placed in the controllers directory?)