After much thought, and perusal of samples, it came to me that I may be thinking about my route construction wrong. While I was learning mvc, all the “basic” sample used the following style:
{controller}/{action}/{id}
And this is how I’ve been thinking about it ever since. This works for the data model driven app, but seems to break down when using a domain model driven app. An example would be in a catalog style application that has the following aggregate chain:
Author -> Book -> Chapter
If one was to have the following controller, using the data driven model, things work:
ChapterController.Edit(id)
And then fetch, update, and commit the exact chapter needed.
But in a domain model, the topmost repository is for Author. You’d have to call the following to get the chapter.
Author author = authorRepository.GetByName(authorName);
Book book = author.LocateBookByName(bookName);
Chapter chapter = book.LocateChapterByName(chapterName);
Then perform your updates and commits. This would seem to want a route and handler more like:
Chapter/Edit/{authorName}/{bookName}/{chapterName}
ChapterController.Edit(string authorName, string bookName, string chapterName);
But even that doesn’t look entirely correct.
So the question is: how would YOU construct this route and handler?
This might expand my understanding greatly.
Thanks in advance for any replies.