An outlet for my obsession with technology
DDD and ASP.NET MVC
I find myself adding child objects within their parents control. For example; if I was going to add a child. I would call the parents controllers addChild action.
/parent/addChild/2
In this case 2 would be the id of the parent that I wanted to add a child to.
Doing it this way I don’t have to keep an internal track of which parent the user wants to add a child to.
For example /child/create does not tell me what parent I am going to associate the child with. In this scenario I would have to put the parent ID in session or something first.
Not sure if what I am doing is “right”….I think so.
No related posts.
| Print article | This entry was posted by Eric Polerecky on May 17, 2009 at 12:03 pm, and is filed under DDD, mvc. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 1 year ago
Ok, I’m starting to think that an internal system for keeping track of what the user is doing is much better then building the parent/child relationship into the controllers.
It starts to get confusing when createChild is in the parent controller but /child/edit/2 is (of course) in the child controller….
and when you start adding all kinds of parent/child relationships it gets really messy.
What if someone beside a parent wants to create a child?
about 1 year ago
Hi,
did you find a practical way ?
I was hoping to make something like a simple actionlink with the parentid inside the parent controller
then inside this action implement a tempdata value and redirect this to the child controller in the create action where i would check the Tempdata field containing the id…
unfortunatly for now i must have made a stupid thing as it is not working…
about 1 year ago
I’m still using the AddChild in the parent controller and using services to handle the actual logic. then redirecting as needed.
The AddChild methods are so thin that, if someone else wants to add a child, I am ok with 2, maybe 3 lines of repetitive code….it does not feel dirty.