Donate

ASP.NET MVP Design Pattern (Simple)

Out of boredom, I decided to read some ASP.NET Articles and came stumbling to Dino Esposito's MVP Flavors. After reading it, I decided to translate this into an ASP.NET application. I revised specifically the Presenter class since this has most of the interaction. Below are some snippets and screen shots: Image: 1. Solution Explorer for the Sample ASP.NET MVP Site
2. On Drop Down Selection of Customer
3. Button Expand Is Clicked, Show other records on other textbox controls.
Presenter Class:
public class Presenter  
    {  
      private IDefaultView view;  
      public Presenter(IDefaultView viewObject)  
      {  
        view = viewObject;  
      }  
      public void InitializeView()  
      {  
:        view.AddCustomer("Alfreds Futterkiste", "ALFKI");  
        view.AddCustomer("Ana Trujillo Emparedados y helados", "ANATR");  
        view.AddCustomer("Antonio Moreno Taquería", "ANTON");  
      }  
      public void ExpandCustomer()  
      {  
        // Get input data  
        string id = view.SelectedCustomer.ToString();  
        // Perform the action (through the model)  
        northwindEntities rep = new northwindEntities();  
        CustomersInfo c = (from cus in rep.Customers  
                 where cus.CustomerID == id  
                 select cus).FirstOrDefault();  
        // Update the view  
        view.CustomerID = c.CustomerID;  
        view.CompanyName = c.CompanyName;  
        view.ContactName = c.ContactName;  
        view.Country = c.Country;  
      }  
    } 
CustomerInfo Class:
// model class to hold results from  
//data context  
public partial class CustomersInfo  
{  
   public string CustomersID { get; set; }  
   public string CompanysName { get; set; }  
   public string ContactsName { get; set; }  
   public string Countrys { get; set; }     
}
Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.