Craig said:
Thanks all..
Checking all the links. Ta.
Does this really just present a new 'presentation' layer, between the
GUI and maybe my Service layer?
Yes, but the presenter layer doesn't have to be a new project, but
rather a new Folder in the UI.
I currently have:
GUI
Makes a call to Service layer: List<Products> = Service.GetProducts();
The GUI will call the presenter and the presenter calls the service
Service
Makes a call to Business:
List<Products> = Business.GetProducts();
Ok
Business:
Makes a call to Data Access:
List<Products> = DataAcess.GetProducts();
DataAccess:
DataReader = Database.CallProcToGetProducts();
Ok
So, to make use of WPF, I need to add a new layer ABOVE service, and
BELOW GUI, which makes calls to the Service, but that returns
different stuff to the GUI?
In order to use N-tier and WPF, you use MVP that sits between the UI and
the service layer, as shown in the examples given to you.
I suggest you take the MVP show parts 1-6, and then it becomes clear as
to what is happening with MVP.
I don't know what you mean by different stuff, other than, you're
calling different methods in the Service layer for CRUD on Shippments as
to Products, if both were need by the application for the UI page.
The presenter sits between the UI and service, as that is the pattern we
use at work for ASP.NET solutions.
UI
Presenter
Services
WCF services
BLL
DAL
You'll notice that the BLL and DAL sit behind the WCF service. The
presenter calls a liked named method in the services layer, the services
method calls a liked named service on the WCF service, the WCF class a
liked named method in the BLL and the BLL calls a liked named method in
the DAL.
You want to call it GetProducts(), then so be it.
Let's say as an example a GridView control on the is a a Web page.
Let's say the GridView was to be loaded on Page_Load.
IView as a getter for the GridView..
public interface IView
{
GridView TheGridView {get;}
}
Now that Web page itself must implement IView, and it going to implement
a get Interface for TheGridView.
class ProductPage :IView
{
public GridView TheGridView
{
get {return GridView1; } // the actual control name of the form
GridView1
protected Page_Load(sender object, evtargs e)
{
mpresenter.PageLoad();
}
ProductPage passes and instance of itself and a instance of the service
in the service layer.
public Presnter()
{
public void PageLoad()
{
mview.TheGridView.Datasource = mservice.GetProducts();
mview.TheGridView.DataBind();
}
}
GridView1 is now populated and given back to the page
That's one way of doing it with MVP.
In some cases, the Presenter has some business rules in it. The Web UI
pages we use are dumb UI(s). And all they do is pass control to a
Presenter.Method().