.Net Framework, Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML

Ado.netAsp.Net 2.0SQLC-SharpXMLFrameworkIISXMLWebServiceArchitecture
UMLProject ManagementSDLCMethodologiesDesign PatterenOOPWCF.Net RemotingWWF
MVPMVCSilver LightN-HibernateAjaxJ-QuerySEO-MarketingSite MapPhp

MVP with Asp.net

Model View Presenter
Model is basically responsible for connecting database and getting and updating data, and communicate with view
Model code sample
using System;
1:using System.Collections.Generic;
2:using System.Text;
3:using BusinessEntities;
4:
5:namespace MVP.Module
6:{
7:
8: /// <summary>
9: /// This is one class of Module section
10: /// </summary>
11: public class ETGModule
12: {
13: public ETGModule()
14: { }
15:
16:
17: public Employee GetEmployeeInfo(int EmpId)
18: {
19: Employee emp = new Employee();
20:
21: /*
22: here to fill up the employee information, module can talk to database directly or indirectly.
23: */
24:
25: return emp;
26: }
27:
28: }
29:}
30:
View is basically an interface, could be a winform or webform
View code sample
using System;
1:using System.Collections.Generic;
2:using System.ComponentModel;
3:using System.Data;
4:using System.Drawing;
5:using System.Text;
6:using System.Windows.Forms;
7:using MVP.Presenter;
8:using BusinessEntities;
9:namespace MVP.View
10:{
11: public partial class ETGView : Form, IPresenter
12: {
13: MVP.Presenter.Presenter _presenter = new MVP.Presenter.Presenter();
14:
15: public ETGView()
16: {
17: InitializeComponent();
18: }
19:
20: private void btnGetEmpInfo_Click(object sender, EventArgs e)
21: {
22: _presenter.GetEmployeeInfo(1);
23:
24: }
25:
26:
27:
28: public Employee EmployeeInfo
29: {
30: get
31: {
32: throw new Exception("The method or operation is not implemented.");
33: }
34: set
35: {
36: if (value != null)
37: {
38: MessageBox.Show(value.Name);
39: MessageBox.Show(value.Email);
40: }
41: }
42: }
43:
44:
45: }
46:}
47:
Presenter code sample
using System;
1:using System.Collections.Generic;
2:using System.Text;
3:using BusinessEntities;
4:
5:namespace MVP.Presenter
6:{
7: public interface IPresenter
8: {
9: Employee EmployeeInfo { get; set; }
10: }
11:}
12:
13:
14:
15://Presenter class implementation
16:
17:using System;
18:using System.Collections.Generic;
19:using System.Text;
20:using BusinessEntities;
21:using MVP.Module;
22:
23:namespace MVP.Presenter
24:{
25: public class Presenter : IPresenter
26: {
27: private Employee _EmployeeInfo;
28:
29: public Presenter()
30: {
31:
32: }
33:
34:
35: public void GetEmployeeInfo(int EmpId)
36: {
37: /*
38: * Here is place for checking any business rules, validation
39: * then make a call to Module
40: * and set the value
41: */
42: ETGModule module = new ETGModule();
43: this.EmployeeInfo = module.GetEmployeeInfo(EmpId);
44: }
45:
46:
47:
48:
49:
50: public Employee EmployeeInfo
51: {
52: get
53: {
54: return this._EmployeeInfo;
55: }
56: set
57: {
58: this._EmployeeInfo = value ;
59: }
60: }
61:
62:
63: }
64:}
65:
Leave your comment.
Name
Email
Comments
Tell Us5874+5 =

Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession

Advertisement
Sponsored by

Privacy Policy ©2009 ETG Consultancy, All Rights Reserved Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML