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.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

  4 Responses to “DDD and ASP.NET MVC”

  1. [...] to VoteDDD and ASP.NET MVC (5/17/2009)Sunday, May 17, 2009 from Eric PolereckyI find myself adding child objects within their parents [...]

  2. 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?

  3. 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…

  4. 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.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 eric.polerecky.com Suffusion theme by Sayontan Sinha