Application Services

0 views
Skip to first unread message

Paul

unread,
Nov 23, 2009, 2:26:54 PM11/23/09
to S#arp Architecture
Hi,

Just want to clear up where my view models sit in my s#arp project, at
the moment they are in a ViewModels folder inside my web application.

I have lots of custom view models which are used in my views, most of
these are automapped using AutoMapper in my controllers.

However i now want to return custom view models from my
ApplicationServices project, but to do this i would need to reference
my web project in my services app which doesn't seem correct.

Would moving the ViewModels to my Core project work or am i missing
something here?

Thanks everyone!

Paul Hinett

Kevin Amerson

unread,
Nov 23, 2009, 2:39:36 PM11/23/09
to sharp-arc...@googlegroups.com
I'm not sure there is much room to share DTOs between views since they are so specific.  That is probably the motivation behind including them in the particular controllers that are using them.

So when an application service needs a DTO I think the same logic applies, create it in with the application service.  This might make you go from DTO to DTO in some cases I guess, but it seems ok to maintain the separation.  If at some point it gets out of hand I would put the largely reused or complex DTOs into their own assembly. 

I have this case too where I moved some classes to a X.Web.Models library.  At that point they aren't really DTOs, they are more of a specific web model shared between controllers and views.  I guess that makes it more of a MMVC architecture ;).  It just totally depends on the purpose of the objects, are they really ViewModels or something else?  How they're being used, etc...

Putting them in Core might unnecessarily couple your domain model to ASP.NET MVC and/or other references that may be undesired.

Kevin


--

You received this message because you are subscribed to the Google Groups "S#arp Architecture" group.
To post to this group, send email to sharp-arc...@googlegroups.com.
To unsubscribe from this group, send email to sharp-architect...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sharp-architecture?hl=.



Paul Hinett

unread,
Nov 25, 2009, 2:48:48 PM11/25/09
to sharp-arc...@googlegroups.com

Hi Kevin,

 

Thanks for your response, I too have thought about putting them in their own class library.

 

I may not have my architecture setup correct anyway... should i be returning a DTO object from my application service? In my controller i need information from multiple repositories...i am returning mp3 dj mixes from the database for a specific genre the user has chosen, but also want to display information about the genre too.

 

I also need to return additional information if a user is logged in, for each returned dj mix i need to check to see if the logged in user has added each mix to their favourites...how can I do this in the most efficient way...sorry if this is off topic!

 

What is the best way to return all this data from the application service? Should i be doing it like this or should i do all this inside my controller from multiple repositories?

 

Paul

Reply all
Reply to author
Forward
0 new messages