Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# MVC3
I'm working on a small simple MVC 3 project. I have three layers basically.
 
Layer One - UI - Controllers, Views
Layer Two - Models
Layer Three - Business rules.
 
With Layer One - UI - I created a reference to Models and Business Rules.
 
With Business Rules, I created a series of Interfaces and I applied those interfaces to the Controllers in UI. I used Ninject Dependency Injection.
 
Simple so far - the basic idea works but this is where I'm stuck.
 
I created a WCF as a separate project. The WCF works just fine in preliminary tests but I came to the conclusion that I'm not doing a true separation of code in the controller.
 
In Layer One (UI) I added a web reference to the WCF and brought back a list of items in a simple Controller command like this:
 
Using (WCF w = new WCF()
..w.GetListTeams()
..flood the view. Blah blah.
 
It works but I know my gut is telling me that this is the "wrong approach" when it comes to true coding of separation of layers.
 
I'm struggling with the idea of passing the reference to the WCF to Layer Two (business rules) via Injection. (Ninject Dependency Injection)
 
Basically, I could add a reference to the UI FROM the business layer but I already added a reference to the Business Layer from the UI - this would cause a "circular reference" which I suspect is a no-no.
 
I've been trying to find articles to tackle this method but alas...
 
Can anyone shed some light on this as to what articles I should review?
 
Thanks,
Glenn
Posted 4-Jan-13 8:51am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The WCF object should be hidden from the presentation layer, I think. It should be in the data layer, it's a way of getting access to data entity objects.
 
I've used Ninject, and discarded it. Your controllers can get passed entity objects instantiated by your own layer within MVC, and that's all I've never needed.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Thanks, Christian.
 
If we created a data layer and created a web reference in that layer, what do we do about the config.sys from the data layer regarding the WCF?
 
And from what I understand I can create a reference from the biz layer to the data layer?
 
Out of curiosity, why did you discard Ninject?
 
thanks,
Glenn
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 PIEBALDconsult 110
4 Sergey Alexandrovich Kryukov 104
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100