Timsen
Timsen

Reputation: 4126

How to handle Service and ViewModels in 2 different projects in asp.net MVC?

I just ran into a problem with my project. I have my MVC website where my ViewModels live, in second proejct i have BuisnessLogic(services) where i have all my funcky logic going on before it gets from db to the view or the other way arround.

Before, i had my ViewModels outside of the web project together with my services, but now after i moved them inside the webproject my services are crashing, because my services used to return ViewModels and they no longer can get them because of the circular dependency, since website need to get service methods, and services need viewmodels. So basicly i am confused right now, and cant figure out which way to go.

Should i just move Services up into website project together with ViewModels? Or have i misunderstood the purpose of the services in MVC? Or maybe there are some other way to keep serivces separated from web project?

Upvotes: 1

Views: 657

Answers (1)

stink
stink

Reputation: 865

There is no official documented way or standard best practice for this. It is up to you. Some people like that about MVC others think it creates unorganized code. Just maintain 3 tier architecture and you can't go wrong.

MVC + 3 tier; where ViewModels come into play?

Upvotes: 1

Related Questions